github
DocsBlog
fontcolor_theme
package

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

SQLiteStatement [source]
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();
}
SQLiteDatabaseTransaction [source]
export class SQLiteDatabaseTransaction extends DatabaseTransaction {
    connection?: SQLiteConnection;
    async begin();
    async commit();
    async rollback();
}
SQLiteConnection [source]
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>;
}
SQLiteConnectionPool [source]
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);
}
SQLitePersistence [source]
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>;
}
SQLiteQueryResolver [source]
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>;
}
SQLiteDatabaseQuery [source]
export class SQLiteDatabaseQuery<T extends OrmEntity> extends SQLDatabaseQuery<T> {
}
SQLiteDatabaseQueryFactory [source]
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>;
}
SQLiteDatabaseAdapter [source]
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;
}
SQLitePlatform [source]
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;
}
SQLiteSchemaParser [source]
export class SQLiteSchemaParser extends SchemaParser {
    async parse(database: DatabaseModel, limitTableNames?: string[]);
}

Const

sqliteSerializer [source]
SQLiteSerializer

Functions

isJsonLike [source]
(type: Type): boolean