Skip to content

Engine

Defined in: engine.ts:151

Database engine interface. All dialect-specific engines (SQLite, Postgres, MySQL, MongoDB) implement this contract so repositories can work against any backend without code changes.

readonly dialect: Dialect

Defined in: engine.ts:157

The dialect function used to translate checked filter expressions into database-specific queries. Set by each engine with a sensible default and optionally overridden by the user at engine creation.


readonly maxParams: number

Defined in: engine.ts:168

Maximum number of bind parameters the engine supports per statement. Used by the repository layer to chunk batch operations.

  • SQLite: 999
  • Postgres: 65535
  • MySQL: 65535
  • MongoDB: Infinity (no parameter limit)

close(): Promise<void>

Defined in: engine.ts:249

Close the underlying connection or client. After calling this method the engine must not be used.

Promise<void>


count(opts): Promise<number>

Defined in: engine.ts:224

Count rows/documents matching the filter.

EngineCountOptions

Promise<number>


deleteMany(opts): Promise<number>

Defined in: engine.ts:219

Delete multiple rows/documents matching the filter. Returns the number of rows deleted.

EngineDeleteManyOptions

Promise<number>


deleteOne(opts): Promise<boolean>

Defined in: engine.ts:196

Delete a single row/document matching the filter. Returns true if a row was deleted, false otherwise.

EngineDeleteOptions

Promise<boolean>


execute<T>(query, params?): Promise<T[]>

Defined in: engine.ts:235

Execute a raw query against the underlying database. This is the escape hatch for queries that cannot be expressed through the higher-level methods.

For SQL engines, query is a SQL string and params contains bind values. For document engines (e.g. MongoDB), query is a command object and params is unused.

T = Record<string, unknown>

string | object

unknown[]

Promise<T[]>


findMany<T>(opts): Promise<T[]>

Defined in: engine.ts:179

Find all rows/documents matching the filter.

T = Record<string, unknown>

EngineFindOptions

Promise<T[]>


findOne<T>(opts): Promise<T | undefined>

Defined in: engine.ts:174

Find a single row/document matching the filter. Returns undefined if no match is found.

T = Record<string, unknown>

EngineFindOptions

Promise<T | undefined>


insertMany<T>(opts): Promise<T[]>

Defined in: engine.ts:203

Insert multiple rows/documents and return all inserted records. The engine automatically chunks the operation based on maxParams to stay within bind-parameter limits.

T = Record<string, unknown>

EngineInsertManyOptions

Promise<T[]>


insertOne<T>(opts): Promise<T>

Defined in: engine.ts:184

Insert a single row/document and return the inserted record.

T = Record<string, unknown>

EngineInsertOptions

Promise<T>


replaceMany<T>(opts): Promise<T[]>

Defined in: engine.ts:213

Replace multiple existing rows/documents identified by their key columns and return all updated records. Uses CASE-based UPDATE for SQL engines, which physically cannot create new rows.

The engine automatically chunks the operation based on maxParams to stay within bind-parameter limits.

T = Record<string, unknown>

EngineReplaceManyOptions

Promise<T[]>


transaction<T>(fn): Promise<T>

Defined in: engine.ts:243

Execute a function within a transaction. All engine method calls made through the transactional engine share the same transaction context. The transaction is committed when the callback resolves and rolled back if it throws.

T

(tx) => Promise<T>

Promise<T>


updateOne<T>(opts): Promise<T | undefined>

Defined in: engine.ts:190

Update a single row/document matching the filter and return the updated record.

T = Record<string, unknown>

EngineUpdateOptions

Promise<T | undefined>