| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -82,6 +82,29 @@ console.log(query.all()); | |||
| 82 | 82 | // Prints: [ { key: 1, value: 'hello' }, { key: 2, value: 'world' } ] | |
| 83 | 83 | ``` | |
| 84 | 84 | ||
| 85 | + ## Type conversion between JavaScript and SQLite | ||
| 86 | + | ||
| 87 | + When Node.js writes to or reads from SQLite, it is necessary to convert between | ||
| 88 | + JavaScript data types and SQLite's [data types][]. Because JavaScript supports | ||
| 89 | + more data types than SQLite, only a subset of JavaScript types are supported. | ||
| 90 | + Attempting to write an unsupported data type to SQLite will result in an | ||
| 91 | + exception. | ||
| 92 | + | ||
| 93 | + | Storage class | JavaScript to SQLite | SQLite to JavaScript | | ||
| 94 | + | ------------- | -------------------------- | ------------------------------------- | | ||
| 95 | + | `NULL` | {null} | {null} | | ||
| 96 | + | `INTEGER` | {number} or {bigint} | {number} or {bigint} _(configurable)_ | | ||
| 97 | + | `REAL` | {number} | {number} | | ||
| 98 | + | `TEXT` | {string} | {string} | | ||
| 99 | + | `BLOB` | {TypedArray} or {DataView} | {Uint8Array} | | ||
| 100 | + | ||
| 101 | + APIs that read values from SQLite have a configuration option that determines | ||
| 102 | + whether `INTEGER` values are converted to `number` or `bigint` in JavaScript, | ||
| 103 | + such as the `readBigInts` option for statements and the `useBigIntArguments` | ||
| 104 | + option for user-defined functions. If Node.js reads an `INTEGER` value from | ||
| 105 | + SQLite that is outside the JavaScript [safe integer][] range, and the option to | ||
| 106 | + read BigInts is not enabled, then an `ERR_OUT_OF_RANGE` error will be thrown. | ||
| 107 | + | ||
| 85 | 108 | ## Class: `DatabaseSync` | |
| 86 | 109 | ||
| 87 | 110 | <!-- YAML | |
@@ -1187,29 +1210,6 @@ added: v24.9.0 | |||
| 1187 | 1210 | ||
| 1188 | 1211 | Resets the LRU cache, clearing all stored prepared statements. | |
| 1189 | 1212 | ||
| 1190 | - ### Type conversion between JavaScript and SQLite | ||
| 1191 | - | ||
| 1192 | - When Node.js writes to or reads from SQLite, it is necessary to convert between | ||
| 1193 | - JavaScript data types and SQLite's [data types][]. Because JavaScript supports | ||
| 1194 | - more data types than SQLite, only a subset of JavaScript types are supported. | ||
| 1195 | - Attempting to write an unsupported data type to SQLite will result in an | ||
| 1196 | - exception. | ||
| 1197 | - | ||
| 1198 | - | Storage class | JavaScript to SQLite | SQLite to JavaScript | | ||
| 1199 | - | ------------- | -------------------------- | ------------------------------------- | | ||
| 1200 | - | `NULL` | {null} | {null} | | ||
| 1201 | - | `INTEGER` | {number} or {bigint} | {number} or {bigint} _(configurable)_ | | ||
| 1202 | - | `REAL` | {number} | {number} | | ||
| 1203 | - | `TEXT` | {string} | {string} | | ||
| 1204 | - | `BLOB` | {TypedArray} or {DataView} | {Uint8Array} | | ||
| 1205 | - | ||
| 1206 | - APIs that read values from SQLite have a configuration option that determines | ||
| 1207 | - whether `INTEGER` values are converted to `number` or `bigint` in JavaScript, | ||
| 1208 | - such as the `readBigInts` option for statements and the `useBigIntArguments` | ||
| 1209 | - option for user-defined functions. If Node.js reads an `INTEGER` value from | ||
| 1210 | - SQLite that is outside the JavaScript [safe integer][] range, and the option to | ||
| 1211 | - read BigInts is not enabled, then an `ERR_OUT_OF_RANGE` error will be thrown. | ||
| 1212 | - | ||
| 1213 | 1213 | ## `sqlite.backup(sourceDb, path[, options])` | |
| 1214 | 1214 | ||
| 1215 | 1215 | <!-- YAML | |
| Back | FazBrowse Home | New Git URL |
0 commit comments