JavaScript 和 SQLite 之间的类型转换
【Type conversion between JavaScript and SQLite】
当 Node.js 向 SQLite 写入或从 SQLite 读取数据时,有必要在 JavaScript 数据类型和 SQLite 的 数据类型 之间进行转换。由于 JavaScript 支持的数据类型比 SQLite 多,因此只支持 JavaScript 类型的一个子集。试图向 SQLite 写入不受支持的数据类型会导致异常。
【When Node.js writes to or reads from SQLite it is necessary to convert between JavaScript data types and SQLite's data types. Because JavaScript supports more data types than SQLite, only a subset of JavaScript types are supported. Attempting to write an unsupported data type to SQLite will result in an exception.】
| SQLite | JavaScript |
|---|---|
NULL | <null> |
INTEGER | <number> 或 <bigint> |
REAL | <number> |
TEXT | <string> |
BLOB | <TypedArray> 或 <DataView> |