File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -394,3 +394,21 @@ When retrieving rows, the types are mapped back to JavaScript types:
394
394
| ` TEXT ` | ` string ` |
395
395
| ` TEXT ` with JSON subtype | ` object ` (` JSON.parse() ` ) |
396
396
| ` BLOB ` | ` Uint8Array ` |
397
+
398
+ Note: We only support ` Uint8Array ` for the ` BLOB ` type as V8 Fast API will
399
+ optimize for it instead of other arrays like ` Uint16Array ` . And it is also to
400
+ stay consistent: we only support passing ` Uint8Array ` and we consistently return
401
+ ` Uint8Array ` when we return a ` BLOB ` to JS. It is easy to support passing all
402
+ typed arrays with good performance, but then at the time we have to retreive
403
+ again we don't know what the original typed array type was, as the only type
404
+ into in the column is that it is a ` BLOB ` .
405
+
406
+ You can easily convert between other typed arrays and ` Uint8Array ` like this:
407
+
408
+ ``` ts
409
+ const f32 = new Float32Array (1 );
410
+ const u8 = new Uint8Array (f32 .buffer ); // no copy, can pass this
411
+
412
+ const u8FromSqlite = new Uint8Array (4 );
413
+ const f32FromSqlite = new Float32Array (u8FromSqlite .buffer ); // safely convert back when retrieved from sqlite, no copy
414
+ ```
You can’t perform that action at this time.
0 commit comments