File tree Expand file tree Collapse file tree 4 files changed +578
-1
lines changed Expand file tree Collapse file tree 4 files changed +578
-1
lines changed Original file line number Diff line number Diff line change @@ -347,6 +347,31 @@ added: v22.5.0
347347Compiles a SQL statement into a [ prepared statement] [ ] . This method is a wrapper
348348around [ ` sqlite3_prepare_v2() ` ] [ ] .
349349
350+ ### ` database.createTagStore(max_size) `
351+
352+ <!-- YAML
353+ added: v24.3.0
354+ -->
355+
356+ * ` max_size ` {integer} The maximum number of prepared statements to cache.
357+ ** Default:** ` 1000 ` .
358+ * Returns: {SqlTagStore} A new tag store for caching prepared statements.
359+
360+ Creates a new ` SqlTagStore ` instance, which can be used with tagged template
361+ literals to execute prepared statements. The ` max_size ` parameter controls the
362+ size of the LRU cache used to store prepared statements.
363+
364+ ``` mjs
365+ import { DatabaseSync } from ' node:sqlite' ;
366+
367+ const db = new DatabaseSync (' :memory:' );
368+ const sql = db .createTagStore ();
369+
370+ db .exec (' CREATE TABLE users (id INT, name TEXT)' );
371+ const user = sql .get ` INSERT INTO users VALUES (1, 'Alice')` ;
372+ console .log (user); // { id: 1, name: 'Alice' }
373+ ```
374+
350375### ` database.createSession([options]) `
351376
352377<!-- YAML
You can’t perform that action at this time.
0 commit comments