Skip to content

Commit 47bf586

Browse files
Renegade334aduh95
authored andcommitted
doc: separate in-types and out-types in SQLite conversion docs
PR-URL: #62034 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
1 parent 5ce06b5 commit 47bf586

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

doc/api/sqlite.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,19 +1175,26 @@ Resets the LRU cache, clearing all stored prepared statements.
11751175

11761176
### Type conversion between JavaScript and SQLite
11771177

1178-
When Node.js writes to or reads from SQLite it is necessary to convert between
1178+
When Node.js writes to or reads from SQLite, it is necessary to convert between
11791179
JavaScript data types and SQLite's [data types][]. Because JavaScript supports
11801180
more data types than SQLite, only a subset of JavaScript types are supported.
11811181
Attempting to write an unsupported data type to SQLite will result in an
11821182
exception.
11831183

1184-
| SQLite | JavaScript |
1185-
| --------- | -------------------------- |
1186-
| `NULL` | {null} |
1187-
| `INTEGER` | {number} or {bigint} |
1188-
| `REAL` | {number} |
1189-
| `TEXT` | {string} |
1190-
| `BLOB` | {TypedArray} or {DataView} |
1184+
| Storage class | JavaScript to SQLite | SQLite to JavaScript |
1185+
| ------------- | -------------------------- | ------------------------------------- |
1186+
| `NULL` | {null} | {null} |
1187+
| `INTEGER` | {number} or {bigint} | {number} or {bigint} _(configurable)_ |
1188+
| `REAL` | {number} | {number} |
1189+
| `TEXT` | {string} | {string} |
1190+
| `BLOB` | {TypedArray} or {DataView} | {Uint8Array} |
1191+
1192+
APIs that read values from SQLite have a configuration option that determines
1193+
whether `INTEGER` values are converted to `number` or `bigint` in JavaScript,
1194+
such as the `readBigInts` option for statements and the `useBigIntArguments`
1195+
option for user-defined functions. If Node.js reads an `INTEGER` value from
1196+
SQLite that is outside the JavaScript [safe integer][] range, and the option to
1197+
read BigInts is not enabled, then an `ERR_OUT_OF_RANGE` error will be thrown.
11911198

11921199
## `sqlite.backup(sourceDb, path[, options])`
11931200

@@ -1551,3 +1558,4 @@ callback function to indicate what type of operation is being authorized.
15511558
[in memory]: https://www.sqlite.org/inmemorydb.html
15521559
[parameters are bound]: https://www.sqlite.org/c3ref/bind_blob.html
15531560
[prepared statement]: https://www.sqlite.org/c3ref/stmt.html
1561+
[safe integer]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger

0 commit comments

Comments
 (0)