API @deepkit/sqlite
npm install @deepkit/sqlite
import { SQLiteDatabaseAdapter } from '@deepkit/sqlite'; import { Database } from '@deepkit/orm'; const adapter = new SQLiteDatabaseAdapter(':memory'); const database = new Database(adapter);
Classes
export class SQLiteStatement extends SQLStatement {
constructor(protected logger: Logger, protected sql: string, protected stmt: sqlite3.Statement, protected stopwatch?: Stopwatch);
async get(params: any[] = []): Promise<any>;
async all(params: any[] = []): Promise<any[]>;
release();
}
export class SQLiteDatabaseTransaction extends DatabaseTransaction {
connection?: SQLiteConnection;
async begin();
async commit();
async rollback();
}
export class SQLiteConnection extends SQLConnection {
platform;
db: sqlite3.Database;
static DatabaseConstructor: any;
constructor(connectionPool: SQLConnectionPool, protected dbPath: string, logger: Logger, transaction?: DatabaseTransaction, stopwatch?: Stopwatch);
async prepare(sql: string);
async run(sql: string, params: any[] = []);
async exec(sql: string);
async getChanges(): Promise<number>;
}
export class SQLiteConnectionPool extends SQLConnectionPool {
maxConnections: number;
constructor(protected dbPath: string | , protected logger: Logger, protected stopwatch?: Stopwatch);
close();
override setLogger(logger: Logger);
async getConnection(transaction?: SQLiteDatabaseTransaction): Promise<SQLiteConnection>;
release(connection: SQLiteConnection);
}
export class SQLitePersistence extends SQLPersistence {
constructor(protected platform: DefaultPlatform, public connectionPool: SQLiteConnectionPool, database: DatabaseSession<any>);
override handleSpecificError(error: Error): Error;
async batchUpdate<T extends OrmEntity>(entity: PreparedEntity, changeSets: DatabasePersistenceChangeSet<T>[]): Promise<void>;
}
export class SQLiteQueryResolver<T extends OrmEntity> extends SQLQueryResolver<T> {
constructor(protected connectionPool: SQLiteConnectionPool, protected platform: DefaultPlatform, classSchema: ReflectionClass<T>, session: DatabaseSession<SQLDatabaseAdapter>);
override handleSpecificError(error: Error): Error;
async delete(model: SQLQueryModel<T>, deleteResult: DeleteResult<T>): Promise<void>;
async patch(model: SQLQueryModel<T>, changes: Changes<T>, patchResult: PatchResult<T>): Promise<void>;
}
export class SQLiteDatabaseQuery<T extends OrmEntity> extends SQLDatabaseQuery<T> {
}
export class SQLiteDatabaseQueryFactory extends SQLDatabaseQueryFactory {
constructor(protected connectionPool: SQLiteConnectionPool, platform: DefaultPlatform, databaseSession: DatabaseSession<any>);
createQuery<T extends OrmEntity>(type?: ReceiveType<T> | ClassType<T> | AbstractClassType<T> | ReflectionClass<T>): SQLiteDatabaseQuery<T>;
}
export class SQLiteDatabaseAdapter extends SQLDatabaseAdapter {
readonly connectionPool: SQLiteConnectionPool;
readonly platform;
constructor(protected sqlitePath: string | = );
setLogger(logger: Logger);
async getInsertBatchSize(schema: ReflectionClass<any>): Promise<number>;
getName(): string;
getSchemaName(): string;
createTransaction(session: DatabaseSession<this>): SQLiteDatabaseTransaction;
createPersistence(session: DatabaseSession<any>): SQLPersistence;
queryFactory(databaseSession: DatabaseSession<any>): SQLiteDatabaseQueryFactory;
disconnect(force?: boolean): void;
}
export class SQLitePlatform extends DefaultPlatform {
override annotationId;
override schemaParserType;
override readonly serializer: Serializer;
constructor();
quoteValue(value: any): string;
applyLimitAndOffset(sql: Sql, limit?: number, offset?: number);
createSqlFilterBuilder(adapter: PreparedAdapter, schema: ReflectionClass<any>, tableName: string): SQLiteFilterBuilder;
getDeepColumnAccessor(table: string, column: string, path: string);
supportsAggregatedAlterTable(): boolean;
getModifyTableDDL(diff: TableDiff, options: MigrateOptions): string[];
/**
* Unfortunately, SQLite does not support composite pks where one is AUTOINCREMENT,
* so we have to flag both as NOT NULL and create in either way a UNIQUE constraint over pks since
* those UNIQUE is otherwise automatically created by the sqlite engine.
*/
normalizeTables(tables: Table[]);
supportsInlinePrimaryKey(): boolean;
getSchemaDelimiter(): string;
getBeginDDL(): string;
getEndDDL(): string;
getAutoIncrement();
getColumnDDL(column: Column);
getForeignKeyDDL(foreignKey: ForeignKey): string;
}
export class SQLiteSchemaParser extends SchemaParser {
async parse(database: DatabaseModel, limitTableNames?: string[]);
}
Const
SQLiteSerializer
Functions
(type: Type): boolean