VersionedSqliteDb Class

Abstract base class for a SQLite database that has RequiredVersionRanges stored in it. This class provides version checking when the database is opened, to guarantee that a valid version of software is always used for access.

Notes:

  • This class may be used either to access a local file, or one stored in a cloud container.
  • Subclasses must provide a myVersion member indicating the version of its software, and implement the createDDL member to create its tables.

Extends

Extended by

Methods

Name Description
constructor(): VersionedSqliteDb    
createDDL(args: any): void Protected Abstract Implement this method to create all tables for this subclass of VersionedSqliteDb when a new database file is created.  
getRequiredVersions(): SQLiteDb.RequiredVersionRanges Get the required version ranges necessary to open this VersionedSqliteDb.  
openDb(dbName: string, openMode: OpenMode | SQLiteDb.OpenParams, container?: CloudSqlite.CloudContainer): void Open this database and verify that this version of the software meets the required version range (as appropriate, read or write) stored in the database.  
setRequiredVersions(versions: SQLiteDb.RequiredVersionRanges): void Change the "versions required to open this database" property stored in this database.  
upgradeSchema(arg: { dbName: string, lockContainer?: { container: CloudSqlite.CloudContainer, user: string }, upgradeFn: () => void }): Promise<void | () => void>    
verifyVersions(): void Protected Verify that this version of the software meets the required version range (as appropriate, read or write) stored in the database.  
createNewDb(fileName: string, setupArgs?: any): void Static Create a new database file for the subclass of VersionedSqliteDb.  

Inherited methods

Name Inherited from Description
abandonChanges(): void Inherited SQLiteDb Abandon (cancel) the outermost transaction, discarding all changes since last save.
closeDb(saveChanges?: boolean): void Inherited SQLiteDb Close SQLiteDb.
createDb(dbName: string): void Inherited SQLiteDb Create a SQLiteDb
createDb(dbName: string, container?: CloudSqlite.CloudContainer, params?: SQLiteDb.CreateParams): void Inherited SQLiteDb  
createTable(args: { addTimestamp?: boolean, columns: string, constraints?: string, tableName: string }): void Protected Inherited SQLiteDb Create a new table in this database.
dispose(): void Inherited SQLiteDb alias for closeDb.
executeSQL(sql: string): DbResult Inherited SQLiteDb execute an SQL statement
readLastModTime(tableName: string, rowId: number): Date Inherited SQLiteDb Get the last modified date for a row in a table of this database.
saveChanges(): void Inherited SQLiteDb Commit the outermost transaction, writing changes to the file.
vacuum(args?: SQLiteDb.VacuumDbArgs): void Inherited SQLiteDb vacuum this database
withOpenDb<T>(args: SQLiteDb.WithOpenDbArgs, operation: () => T): T Inherited SQLiteDb Open a database, perform an operation, then close the database.
withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T): T Inherited SQLiteDb Use a prepared SQL statement, potentially from the statement cache.
withSavePoint(savePointName: string, operation: () => void): void Inherited SQLiteDb Perform an operation on this database within a savepoint.
withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T): T Inherited SQLiteDb Prepare and execute a callback on a SQL statement.

Properties

Name Type Description
_versionProps Protected Static { name: "versions", namespace: "SQLiteDb" }    
myVersion Abstract string The current semver "persistence version" of this class.  

Inherited properties

Name Type Inherited from Description
isOpen Accessor Inherited ReadOnly boolean SQLiteDb Returns true if this SQLiteDb is open
isReadonly Accessor Inherited ReadOnly boolean SQLiteDb Returns true if this SQLiteDb is open readonly

Defined in

Last Updated: 17 December, 2024