Skip to main content
Version: Next

SqliteDriver

Generic SQLite driver that uses driverOptions for the Kysely dialect. Use this with any SQLite library by passing a Kysely dialect via driverOptions.

For the default better-sqlite3 experience, use @mikro-orm/sqlite instead.

Hierarchy

Index

Constructors

constructor

Properties

inherited[EntityManagerType]

[EntityManagerType]: SqlEntityManager<SqliteDriver>

readonlyinheritedconfig

Methods

inheritedaggregate

  • aggregate(entityName, pipeline): Promise<any[]>
  • Executes a MongoDB aggregation pipeline (MongoDB driver only).


    Parameters

    Returns Promise<any[]>

inheritedclose

  • close(force): Promise<void>
  • Closes the primary connection and all read replicas.


    Parameters

    • optionalforce: boolean

    Returns Promise<void>

inheritedconnect

  • Opens the primary connection and all read replicas.


    Parameters

    • optionaloptions: { skipOnConnect?: boolean }
      • optionalskipOnConnect: boolean

    Returns Promise<BaseSqliteConnection>

inheritedconvertException

  • Converts native db errors to standardized driver exceptions


    Parameters

    • exception: Error

    Returns DriverException

inheritedcount

  • count<T>(entityName, where, options): Promise<number>
  • Counts entities matching the given condition.


    Parameters

    Returns Promise<number>

inheritedcountVirtual

  • countVirtual<T>(entityName, where, options): Promise<number>

inheritedcreateEntityManager

  • Creates a new EntityManager instance bound to this driver.


    Parameters

    • optionaluseContext: boolean

    Returns SqlEntityManager<SqliteDriver>

inheritedevaluateFormula

  • evaluateFormula(formula, columns, table): string
  • Evaluates a formula callback, handling both string and Raw return values.


    Parameters

    Returns string

inheritedexecute

  • execute<T>(query, params, method, ctx, loggerContext): Promise<T>
  • Parameters

    • query: string | RawQueryFragment<string> | NativeQueryBuilder
    • params: any[] = []
    • method: get | all | run = 'all'
    • optionalctx: any
    • optionalloggerContext: LoggingOptions

    Returns Promise<T>

inheritedfind

  • find<T, P, F, E>(entityName, where, options): Promise<EntityData<T>[]>

inheritedfindOne

  • findOne<T, P, F, E>(entityName, where, options): Promise<null | EntityData<T>>

inheritedfindVirtual

  • findVirtual<T>(entityName, where, options): Promise<EntityData<T>[]>
  • Finds entities backed by a virtual (expression-based) definition.


    Parameters

    Returns Promise<EntityData<T>[]>

inheritedgetConnection

inheritedgetDependencies

  • getDependencies(): string[]
  • Returns the names of native database dependencies required by this driver.


    Returns string[]

inheritedgetMetadata

  • Returns the metadata storage used by this driver.


    Returns MetadataStorage

inheritedgetPlatform

  • Returns the database platform abstraction for this driver.


    Returns AbstractSqlPlatform

inheritedloadFromPivotTable

  • loadFromPivotTable<T, O>(prop, owners, where, orderBy, ctx, options, pivotJoin): Promise<Dictionary<T[]>>
  • When driver uses pivot tables for M:N, this method will load identifiers for given collections from them


    Parameters

    • prop: EntityProperty<any, any>
    • owners: (O extends { [PrimaryKeyProp]?: PK } ? PK extends undefined ? Omit<O<O>, typeof PrimaryKeyProp> : PK extends keyof O<O> ? ReadonlyPrimary<UnwrapPrimary<O<O>[PK<PK>]>> : PK extends keyof O<O>[] ? ReadonlyPrimary<PrimaryPropToType<O<O>, PK<PK>>> : PK : O extends { _id?: PK } ? string | ReadonlyPrimary<PK> : O extends { id?: PK } ? ReadonlyPrimary<PK> : O extends { uuid?: PK } ? ReadonlyPrimary<PK> : O)[][]
    • where: any = ...
    • optionalorderBy: OrderDefinition<T>
    • optionalctx: any
    • optionaloptions: FindOptions<T, any, any, any>
    • optionalpivotJoin: boolean

    Returns Promise<Dictionary<T[]>>

inheritedlockPessimistic

  • lockPessimistic<T>(entity, options): Promise<void>
  • Acquires a pessimistic lock on the given entity.


    Parameters

    Returns Promise<void>

inheritedmapResult

  • mapResult<T>(result, meta, populate, qb, map): null | EntityData<T>

inheritednativeDelete

  • nativeDelete<T>(entityName, where, options): Promise<QueryResult<T>>
  • Deletes rows matching the given condition.


    Parameters

    Returns Promise<QueryResult<T>>

inheritednativeInsert

  • nativeInsert<T>(entityName, data, options): Promise<QueryResult<T>>

inheritednativeInsertMany

  • nativeInsertMany<T>(entityName, data, options, transform): Promise<QueryResult<T>>

inheritednativeUpdate

  • nativeUpdate<T>(entityName, where, data, options): Promise<QueryResult<T>>

inheritednativeUpdateMany

  • nativeUpdateMany<T>(entityName, where, data, options, transform): Promise<QueryResult<T>>

inheritedreconnect

  • Closes all connections and re-establishes them.


    Parameters

    • optionaloptions: { skipOnConnect?: boolean }
      • optionalskipOnConnect: boolean

    Returns Promise<BaseSqliteConnection>

inheritedsetMetadata

  • setMetadata(metadata): void
  • Sets the metadata storage and initializes the comparator for all connections.


    Parameters

    Returns void

inheritedstream

  • stream<T>(entityName, where, options): AsyncIterableIterator<T, any, any>
  • Returns an async iterator that streams query results one entity at a time.


    Parameters

    Returns AsyncIterableIterator<T, any, any>

inheritedsyncCollections

  • syncCollections<T, O>(collections, options): Promise<void>
  • Persists changes to M:N collections (inserts/deletes pivot table rows).


    Parameters

    Returns Promise<void>