Skip to content

Docs: mention which datatypes are supportedΒ #1473

Open
@Quelklef

Description

@Quelklef

Hello,

There does not seem to be documentation on which Javascript datatypes node-sqlite3 supports sorting in a database, nor on the details of data conversion between JS and Sqlite3.

I was able to find this block of code, which seems to be where the JS -> Sqlite3 conversions happen. As far as I can tell:

  • JS string becomes Sqlite3 TEXT
  • JS RegExp is converted to a string via .toString() and becomes Sqlite3 TEXT
  • JS number becomes Sqlite3 INTEGER and FLOAT
  • JS boolean becomes Sqlite3 INTEGER, restricted to 0 and 1
  • JS null becomes Sqlite3 NULL
  • JS Buffer becomes Sqlite3 BLOB
  • JS Date becomes Sqlite3 FLOAT
  • JS object is converted to a string via .toString() and becomes Sqlite3 TEXT. If .toString() does not return a string, the code throws.
  • No other datatypes are supported

I did not find the Sqlite3 -> JS conversion code, but I assume that the rules are as would be expected.

Anyway, I am dropping by just to (1) suggest that this information be documented somewhere, and (2) document it here for anyone in the future who has the same question as me.

I'd be willing to take a shot at doing the documentation myself, if you'd like.

Cheers

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions