Skip to content

Commit e4c6ac3

Browse files
Renegade334juanarbol
authored andcommitted
doc: separate in-types and out-types in SQLite conversion docs
PR-URL: nodejs#62034 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
1 parent 70ecf77 commit e4c6ac3

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

‎doc/api/sqlite.md‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -775,19 +775,26 @@ wrapper around [`sqlite3_sql()`][].
775775

776776
### Type conversion between JavaScript and SQLite
777777

778-
When Node.js writes to or reads from SQLite it is necessary to convert between
778+
When Node.js writes to or reads from SQLite, it is necessary to convert between
779779
JavaScript data types and SQLite's [data types][]. Because JavaScript supports
780780
more data types than SQLite, only a subset of JavaScript types are supported.
781781
Attempting to write an unsupported data type to SQLite will result in an
782782
exception.
783783

784-
| SQLite | JavaScript |
785-
| --------- | -------------------------- |
786-
| `NULL` | {null} |
787-
| `INTEGER` | {number} or {bigint} |
788-
| `REAL` | {number} |
789-
| `TEXT` | {string} |
790-
| `BLOB` | {TypedArray} or {DataView} |
784+
| Storage class | JavaScript to SQLite | SQLite to JavaScript |
785+
| ------------- | -------------------------- | ------------------------------------- |
786+
| `NULL` | {null} | {null} |
787+
| `INTEGER` | {number} or {bigint} | {number} or {bigint} _(configurable)_ |
788+
| `REAL` | {number} | {number} |
789+
| `TEXT` | {string} | {string} |
790+
| `BLOB` | {TypedArray} or {DataView} | {Uint8Array} |
791+
792+
APIs that read values from SQLite have a configuration option that determines
793+
whether `INTEGER` values are converted to `number` or `bigint` in JavaScript,
794+
such as the `readBigInts` option for statements and the `useBigIntArguments`
795+
option for user-defined functions. If Node.js reads an `INTEGER` value from
796+
SQLite that is outside the JavaScript [safe integer][] range, and the option to
797+
read BigInts is not enabled, then an `ERR_OUT_OF_RANGE` error will be thrown.
791798

792799
## `sqlite.backup(sourceDb, destination[, options])`
793800

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

0 commit comments

Comments
 (0)