mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-24 19:44:21 +01:00
Before: ``` penberg@vonneumann perf % node perf-turso.js cpu: Apple M1 runtime: node v22.16.0 (arm64-darwin) benchmark time (avg) (min … max) p75 p99 p999 ----------------------------------------------------------------------- ----------------------------- • Statement ----------------------------------------------------------------------- ----------------------------- Statement.get() bind parameters 1'525 ns/iter (1'482 ns … 1'720 ns) 1'534 ns 1'662 ns 1'720 ns summary for Statement Statement.get() bind parameters penberg@vonneumann perf % bun perf-turso.js cpu: Apple M1 runtime: bun 1.2.15 (arm64-darwin) benchmark time (avg) (min … max) p75 p99 p999 ----------------------------------------------------------------------- ----------------------------- • Statement ----------------------------------------------------------------------- ----------------------------- Statement.get() bind parameters 1'198 ns/iter (1'157 ns … 1'495 ns) 1'189 ns 1'456 ns 1'495 ns summary for Statement Statement.get() bind parameters ``` After: ``` benchmark time (avg) (min … max) p75 p99 p999 ----------------------------------------------------------------------- ----------------------------- • Statement ----------------------------------------------------------------------- ----------------------------- Statement.get() bind parameters 1'206 ns/iter (1'180 ns … 1'402 ns) 1'208 ns 1'365 ns 1'402 ns summary for Statement Statement.get() bind parameters penberg@vonneumann perf % bun perf-turso.js cpu: Apple M1 runtime: bun 1.2.15 (arm64-darwin) benchmark time (avg) (min … max) p75 p99 p999 ----------------------------------------------------------------------- ----------------------------- • Statement ----------------------------------------------------------------------- ----------------------------- Statement.get() bind parameters 1'019 ns/iter (980 ns … 1'360 ns) 1'005 ns 1'270 ns 1'360 ns summary for Statement Statement.get() bind parameters ```
111 lines
2.6 KiB
TypeScript
111 lines
2.6 KiB
TypeScript
/* auto-generated by NAPI-RS */
|
|
/* eslint-disable */
|
|
/** A database connection. */
|
|
export declare class Database {
|
|
/**
|
|
* Creates a new database instance.
|
|
*
|
|
* # Arguments
|
|
* * `path` - The path to the database file.
|
|
*/
|
|
constructor(path: string)
|
|
/** Returns whether the database is in memory-only mode. */
|
|
get memory(): boolean
|
|
/**
|
|
* Executes a batch of SQL statements.
|
|
*
|
|
* # Arguments
|
|
*
|
|
* * `sql` - The SQL statements to execute.
|
|
*
|
|
* # Returns
|
|
*/
|
|
batch(sql: string): void
|
|
/**
|
|
* Prepares a statement for execution.
|
|
*
|
|
* # Arguments
|
|
*
|
|
* * `sql` - The SQL statement to prepare.
|
|
*
|
|
* # Returns
|
|
*
|
|
* A `Statement` instance.
|
|
*/
|
|
prepare(sql: string): Statement
|
|
/**
|
|
* Returns the rowid of the last row inserted.
|
|
*
|
|
* # Returns
|
|
*
|
|
* The rowid of the last row inserted.
|
|
*/
|
|
lastInsertRowid(): number
|
|
/**
|
|
* Returns the number of changes made by the last statement.
|
|
*
|
|
* # Returns
|
|
*
|
|
* The number of changes made by the last statement.
|
|
*/
|
|
changes(): number
|
|
/**
|
|
* Returns the total number of changes made by all statements.
|
|
*
|
|
* # Returns
|
|
*
|
|
* The total number of changes made by all statements.
|
|
*/
|
|
totalChanges(): number
|
|
/**
|
|
* Closes the database connection.
|
|
*
|
|
* # Returns
|
|
*
|
|
* `Ok(())` if the database is closed successfully.
|
|
*/
|
|
close(): void
|
|
/** Runs the I/O loop synchronously. */
|
|
ioLoopSync(): void
|
|
/** Runs the I/O loop asynchronously, returning a Promise. */
|
|
ioLoopAsync(): Promise<void>
|
|
}
|
|
|
|
/** A prepared statement. */
|
|
export declare class Statement {
|
|
reset(): void
|
|
/** Returns the number of parameters in the statement. */
|
|
parameterCount(): number
|
|
/**
|
|
* Returns the name of a parameter at a specific 1-based index.
|
|
*
|
|
* # Arguments
|
|
*
|
|
* * `index` - The 1-based parameter index.
|
|
*/
|
|
parameterName(index: number): string | null
|
|
/**
|
|
* Binds a parameter at a specific 1-based index with explicit type.
|
|
*
|
|
* # Arguments
|
|
*
|
|
* * `index` - The 1-based parameter index.
|
|
* * `value_type` - The type constant (0=null, 1=int, 2=float, 3=text, 4=blob).
|
|
* * `value` - The value to bind.
|
|
*/
|
|
bindAt(index: number, value: unknown): void
|
|
/**
|
|
* Step the statement and return result code:
|
|
* 1 = Row available, 2 = Done, 3 = I/O needed
|
|
*/
|
|
step(): number
|
|
/** Get the current row data according to the presentation mode */
|
|
row(): unknown
|
|
/** Sets the presentation mode to raw. */
|
|
raw(raw?: boolean | undefined | null): void
|
|
/** Sets the presentation mode to pluck. */
|
|
pluck(pluck?: boolean | undefined | null): void
|
|
/** Finalizes the statement. */
|
|
finalize(): void
|
|
}
|