Skip to content

Commit 04d3af2

Browse files
geeksilva97aduh95
authored andcommitted
sqlite,doc: fix StatementSync section
PR-URL: #60474 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 3c808e8 commit 04d3af2

File tree

1 file changed

+114
-114
lines changed

1 file changed

+114
-114
lines changed

doc/api/sqlite.md

Lines changed: 114 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -616,120 +616,6 @@ times with different bound values. Parameters also offer protection against
616616
[SQL injection][] attacks. For these reasons, prepared statements are preferred
617617
over hand-crafted SQL strings when handling user input.
618618

619-
## Class: `SQLTagStore`
620-
621-
<!-- YAML
622-
added: v24.9.0
623-
-->
624-
625-
This class represents a single LRU (Least Recently Used) cache for storing
626-
prepared statements.
627-
628-
Instances of this class are created via the database.createTagStore() method,
629-
not by using a constructor. The store caches prepared statements based on the
630-
provided SQL query string. When the same query is seen again, the store
631-
retrieves the cached statement and safely applies the new values through
632-
parameter binding, thereby preventing attacks like SQL injection.
633-
634-
The cache has a maxSize that defaults to 1000 statements, but a custom size can
635-
be provided (e.g., database.createTagStore(100)). All APIs exposed by this
636-
class execute synchronously.
637-
638-
### `sqlTagStore.all(sqlTemplate[, ...values])`
639-
640-
<!-- YAML
641-
added: v24.9.0
642-
-->
643-
644-
* `sqlTemplate` {Template Literal} A template literal containing the SQL query.
645-
* `...values` {any} Values to be interpolated into the template literal.
646-
* Returns: {Array} An array of objects representing the rows returned by the query.
647-
648-
Executes the given SQL query and returns all resulting rows as an array of objects.
649-
650-
### `sqlTagStore.get(sqlTemplate[, ...values])`
651-
652-
<!-- YAML
653-
added: v24.9.0
654-
-->
655-
656-
* `sqlTemplate` {Template Literal} A template literal containing the SQL query.
657-
* `...values` {any} Values to be interpolated into the template literal.
658-
* Returns: {Object | undefined} An object representing the first row returned by
659-
the query, or `undefined` if no rows are returned.
660-
661-
Executes the given SQL query and returns the first resulting row as an object.
662-
663-
### `sqlTagStore.iterate(sqlTemplate[, ...values])`
664-
665-
<!-- YAML
666-
added: v24.9.0
667-
-->
668-
669-
* `sqlTemplate` {Template Literal} A template literal containing the SQL query.
670-
* `...values` {any} Values to be interpolated into the template literal.
671-
* Returns: {Iterator} An iterator that yields objects representing the rows returned by the query.
672-
673-
Executes the given SQL query and returns an iterator over the resulting rows.
674-
675-
### `sqlTagStore.run(sqlTemplate[, ...values])`
676-
677-
<!-- YAML
678-
added: v24.9.0
679-
-->
680-
681-
* `sqlTemplate` {Template Literal} A template literal containing the SQL query.
682-
* `...values` {any} Values to be interpolated into the template literal.
683-
* Returns: {Object} An object containing information about the execution, including `changes` and `lastInsertRowid`.
684-
685-
Executes the given SQL query, which is expected to not return any rows (e.g., INSERT, UPDATE, DELETE).
686-
687-
### `sqlTagStore.size()`
688-
689-
<!-- YAML
690-
added: v24.9.0
691-
-->
692-
693-
* Returns: {integer} The number of prepared statements currently in the cache.
694-
695-
A read-only property that returns the number of prepared statements currently in the cache.
696-
697-
### `sqlTagStore.capacity`
698-
699-
<!-- YAML
700-
added: v24.9.0
701-
-->
702-
703-
* Returns: {integer} The maximum number of prepared statements the cache can hold.
704-
705-
A read-only property that returns the maximum number of prepared statements the cache can hold.
706-
707-
### `sqlTagStore.db`
708-
709-
<!-- YAML
710-
added: v24.9.0
711-
-->
712-
713-
* {DatabaseSync} The `DatabaseSync` instance that created this `SQLTagStore`.
714-
715-
A read-only property that returns the `DatabaseSync` object associated with this `SQLTagStore`.
716-
717-
### `sqlTagStore.reset()`
718-
719-
<!-- YAML
720-
added: v24.9.0
721-
-->
722-
723-
Resets the LRU cache, clearing all stored prepared statements.
724-
725-
### `sqlTagStore.clear()`
726-
727-
<!-- YAML
728-
added: v24.9.0
729-
-->
730-
731-
An alias for `sqlTagStore.reset()`.
732-
733619
### `statement.all([namedParameters][, ...anonymousParameters])`
734620

735621
<!-- YAML
@@ -956,6 +842,120 @@ added: v22.5.0
956842
The source SQL text of the prepared statement. This property is a
957843
wrapper around [`sqlite3_sql()`][].
958844

845+
## Class: `SQLTagStore`
846+
847+
<!-- YAML
848+
added: v24.9.0
849+
-->
850+
851+
This class represents a single LRU (Least Recently Used) cache for storing
852+
prepared statements.
853+
854+
Instances of this class are created via the database.createTagStore() method,
855+
not by using a constructor. The store caches prepared statements based on the
856+
provided SQL query string. When the same query is seen again, the store
857+
retrieves the cached statement and safely applies the new values through
858+
parameter binding, thereby preventing attacks like SQL injection.
859+
860+
The cache has a maxSize that defaults to 1000 statements, but a custom size can
861+
be provided (e.g., database.createTagStore(100)). All APIs exposed by this
862+
class execute synchronously.
863+
864+
### `sqlTagStore.all(sqlTemplate[, ...values])`
865+
866+
<!-- YAML
867+
added: v24.9.0
868+
-->
869+
870+
* `sqlTemplate` {Template Literal} A template literal containing the SQL query.
871+
* `...values` {any} Values to be interpolated into the template literal.
872+
* Returns: {Array} An array of objects representing the rows returned by the query.
873+
874+
Executes the given SQL query and returns all resulting rows as an array of objects.
875+
876+
### `sqlTagStore.get(sqlTemplate[, ...values])`
877+
878+
<!-- YAML
879+
added: v24.9.0
880+
-->
881+
882+
* `sqlTemplate` {Template Literal} A template literal containing the SQL query.
883+
* `...values` {any} Values to be interpolated into the template literal.
884+
* Returns: {Object | undefined} An object representing the first row returned by
885+
the query, or `undefined` if no rows are returned.
886+
887+
Executes the given SQL query and returns the first resulting row as an object.
888+
889+
### `sqlTagStore.iterate(sqlTemplate[, ...values])`
890+
891+
<!-- YAML
892+
added: v24.9.0
893+
-->
894+
895+
* `sqlTemplate` {Template Literal} A template literal containing the SQL query.
896+
* `...values` {any} Values to be interpolated into the template literal.
897+
* Returns: {Iterator} An iterator that yields objects representing the rows returned by the query.
898+
899+
Executes the given SQL query and returns an iterator over the resulting rows.
900+
901+
### `sqlTagStore.run(sqlTemplate[, ...values])`
902+
903+
<!-- YAML
904+
added: v24.9.0
905+
-->
906+
907+
* `sqlTemplate` {Template Literal} A template literal containing the SQL query.
908+
* `...values` {any} Values to be interpolated into the template literal.
909+
* Returns: {Object} An object containing information about the execution, including `changes` and `lastInsertRowid`.
910+
911+
Executes the given SQL query, which is expected to not return any rows (e.g., INSERT, UPDATE, DELETE).
912+
913+
### `sqlTagStore.size()`
914+
915+
<!-- YAML
916+
added: v24.9.0
917+
-->
918+
919+
* Returns: {integer} The number of prepared statements currently in the cache.
920+
921+
A read-only property that returns the number of prepared statements currently in the cache.
922+
923+
### `sqlTagStore.capacity`
924+
925+
<!-- YAML
926+
added: v24.9.0
927+
-->
928+
929+
* Returns: {integer} The maximum number of prepared statements the cache can hold.
930+
931+
A read-only property that returns the maximum number of prepared statements the cache can hold.
932+
933+
### `sqlTagStore.db`
934+
935+
<!-- YAML
936+
added: v24.9.0
937+
-->
938+
939+
* {DatabaseSync} The `DatabaseSync` instance that created this `SQLTagStore`.
940+
941+
A read-only property that returns the `DatabaseSync` object associated with this `SQLTagStore`.
942+
943+
### `sqlTagStore.reset()`
944+
945+
<!-- YAML
946+
added: v24.9.0
947+
-->
948+
949+
Resets the LRU cache, clearing all stored prepared statements.
950+
951+
### `sqlTagStore.clear()`
952+
953+
<!-- YAML
954+
added: v24.9.0
955+
-->
956+
957+
An alias for `sqlTagStore.reset()`.
958+
959959
### Type conversion between JavaScript and SQLite
960960

961961
When Node.js writes to or reads from SQLite it is necessary to convert between

0 commit comments

Comments
 (0)