mirror of
https://github.com/asg017/sqlite-vec.git
synced 2026-04-25 00:36:56 +02:00
node:sqlite sample
This commit is contained in:
parent
d1d1ed7a57
commit
dbc5098114
4 changed files with 81 additions and 0 deletions
12
examples/simple-node2/tmp.mjs
Normal file
12
examples/simple-node2/tmp.mjs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import { DatabaseSync } from "node:sqlite";
|
||||
import * as sqliteVec from "sqlite-vec";
|
||||
|
||||
const db = new DatabaseSync(":memory:", { allowExtension: true });
|
||||
sqliteVec.load(db);
|
||||
|
||||
const embedding = new Float32Array([0.1, 0.2, 0.3, 0.4]);
|
||||
const { result } = db
|
||||
.prepare("select vec_length(?) as result")
|
||||
.get(new Uint8Array(embedding.buffer));
|
||||
|
||||
console.log(result); // 4
|
||||
Loading…
Add table
Add a link
Reference in a new issue