Interface: SqlExecutor
Interface: SqlExecutor
Section titled “Interface: SqlExecutor”Defined in: server/src/adapters/executor.ts:12
A minimal contract every SQL driver (better-sqlite3, D1)
implements. The rest of @sh1n4ps/plasma-server builds on this so a swap between
drivers only touches this adapter layer.
All methods are async because D1 is inherently async; synchronous drivers (better-sqlite3) simply wrap their result in a resolved promise.
Methods
Section titled “Methods”all(
sql):Promise<Record<string,unknown>[]>
Defined in: server/src/adapters/executor.ts:14
Execute a query and return the rows.
Parameters
Section titled “Parameters”CompiledSql
Returns
Section titled “Returns”Promise<Record<string, unknown>[]>
exec()
Section titled “exec()”exec(
sql):Promise<void>
Defined in: server/src/adapters/executor.ts:16
Execute a write (INSERT / UPDATE / DELETE / DDL). Returns nothing.
Parameters
Section titled “Parameters”CompiledSql
Returns
Section titled “Returns”Promise<void>
execWithMeta()
Section titled “execWithMeta()”execWithMeta(
sql):Promise<{meta: {changes:number;last_row_id?:number;duration?:number; }; }>
Defined in: server/src/adapters/executor.ts:18
Execute a write and return driver metadata for non-CAS observability.
Parameters
Section titled “Parameters”CompiledSql
Returns
Section titled “Returns”Promise<{ meta: { changes: number; last_row_id?: number; duration?: number; }; }>
execReturningRows()
Section titled “execReturningRows()”execReturningRows<
Row>(sql):Promise<Row[]>
Defined in: server/src/adapters/executor.ts:26
Execute one statement that returns rows (e.g. UPDATE ... RETURNING).
Type Parameters
Section titled “Type Parameters”Row = Record<string, unknown>
Parameters
Section titled “Parameters”CompiledSql
Returns
Section titled “Returns”Promise<Row[]>
transaction()
Section titled “transaction()”transaction<
T>(fn):Promise<T>
Defined in: server/src/adapters/executor.ts:32
Run fn inside a transaction. The passed executor is scoped to that
transaction — writes issued via it must succeed atomically with the
fn’s return, or roll back if it throws.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”(tx) => Promise<T>
Returns
Section titled “Returns”Promise<T>