withPreparedSqliteStatement Method
Use a prepared SQL statement, potentially from the statement cache. If the requested statement doesn't exist in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved in the statement cache so it can be reused in the future. Use this method for SQL statements that will be reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding the oldest statements as it fills. For statements you don't intend to reuse, instead use withSqliteStatement.
withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors: booleantrue): T
@returns the value returned by callback
.
Parameter | Type | Description |
---|---|---|
sql | string | The SQLite SQL statement to execute |
callback | (stmt: SqliteStatement) => T | the callback to invoke on the prepared statement |
logErrors | boolean | Determine if errors are logged or not |
Returns - T
the value returned by callback
.
Defined in
- core/backend/src/IModelDb.ts Line 566
Last Updated: 21 November, 2024