Type conversion
Review converting from JavaScript to SQL types.
When working in JavaScript, types must properly map to the protocol's requirements. Both SQLite and Tableland's constrained version of it have some types that don't perfectly align. Additionally, any object that implements a toSQL
method can also be used.
JavaScript | Tableland | Notes |
---|---|---|
null | NULL | |
undefined | NULL | |
Number | INTEGER | Tableland supports 64-bit signed INTEGERs internally, and we mostly support BigInt on the client side. These values will be converted to INTEGERs. Note that Javascript integer's are safe up to MAX_SAFE_INTEGER . |
String | TEXT | |
ArrayBuffer | BLOB | |
Booleans | INTEGER | Booleans will be turned into integers where 1 is true and 0 is false . |
Date | INTEGER | Dates are converted to their UNIX timestamp representation. |
Object or JSON | TEXT | A plain old JavaScript object (POGO) that can be converted to JSON strings will be converted to JSON and inserted as TEXT . |