# API `@deepkit/sqlite`

```shell
npm install @deepkit/sqlite
```

```typescript
import { SQLiteDatabaseAdapter } from '@deepkit/sqlite';
import { Database } from '@deepkit/orm';

const adapter = new SQLiteDatabaseAdapter(':memory');

const database = new Database(adapter);
```

## API reference of @deepkit/sqlite

### SQLiteStatement (class)

```typescript
export class SQLiteStatement extends SQLStatement {
    constructor(protected logger: Logger, protected sql: string, protected stmt: sqlite3.Statement, protected stopwatch?: Stopwatch, protected createRow?: RowFactory);
    async get(params: any[] = []): Promise<any>;
    async all(params: any[] = []): Promise<any[]>;
    release();
}
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/sqlite/src/sqlite-adapter.ts#L72

### SQLiteDatabaseTransaction (class)

```typescript
export class SQLiteDatabaseTransaction extends DatabaseTransaction {
    connection?: SQLiteConnection;
    async begin();
    async commit();
    async rollback();
}
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/sqlite/src/sqlite-adapter.ts#L119

### SQLiteConnection (class)

```typescript
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>;
}
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/sqlite/src/sqlite-adapter.ts#L146

### SQLiteConnectionPool (class)

```typescript
export class SQLiteConnectionPool extends SQLConnectionPool {
    constructor(protected dbPath: string | , protected logger: Logger, protected stopwatch?: Stopwatch);
    get maxConnections(): number;
    close();
    override setLogger(logger: Logger);
    async getConnection(transaction?: SQLiteDatabaseTransaction): Promise<SQLiteConnection>;
    release(connection: SQLiteConnection);
}
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/sqlite/src/sqlite-adapter.ts#L233

### SQLitePersistence (class)

```typescript
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>;
}
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/sqlite/src/sqlite-adapter.ts#L331

### SQLiteQueryResolver (class)

```typescript
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>;
}
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/sqlite/src/sqlite-adapter.ts#L479

### SQLiteDatabaseQuery (class)

```typescript
export class SQLiteDatabaseQuery<T extends OrmEntity> extends SQLDatabaseQuery<T> {
}
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/sqlite/src/sqlite-adapter.ts#L641

### SQLiteDatabaseQueryFactory (class)

```typescript
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>;
}
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/sqlite/src/sqlite-adapter.ts#L644

### SQLiteDatabaseAdapter (class)

```typescript
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;
}
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/sqlite/src/sqlite-adapter.ts#L656

### isJsonLike (function)

```typescript
(type: Type): boolean
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/sqlite/src/sqlite-platform.ts#L45

### SQLitePlatform (class)

```typescript
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;
}
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/sqlite/src/sqlite-platform.ts#L52

### SQLiteSchemaParser (class)

```typescript
export class SQLiteSchemaParser extends SchemaParser {
    async parse(database: DatabaseModel, limitTableNames?: string[]);
}
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/sqlite/src/sqlite-schema-parser.ts#L15

### sqliteSerializer (variable)

```typescript
SQLiteSerializer
```

Source: https://github.com/deepkit/deepkit-framework/blob/master/packages/sqlite/src/sqlite-serializer.ts#L30
