bare-sqlite-vector
SQLite Vector bindings for Bare
stable
Source
bare-sqlite-vector — SQLite Vector bindings for Bare. It is a native addon.
npm i bare-sqlite-vectorUsage
const { DatabaseSync } = require('bare-sqlite')
const vector = require('bare-sqlite-vector')
const db = new DatabaseSync(':memory:')
vector.register(db)
db.exec(`
CREATE TABLE points (id INTEGER PRIMARY KEY, v BLOB);
INSERT INTO points (v) VALUES (vector_as_f32('[1.0, 0.0, 0.0, 0.0]'));
INSERT INTO points (v) VALUES (vector_as_f32('[0.0, 1.0, 0.0, 0.0]'));
`)
db.prepare("SELECT vector_init('points', 'v', 'type=FLOAT32,dimension=4,distance=L2')").get()
const rows = db
.prepare(
"SELECT rowid, distance FROM vector_full_scan('points', 'v', vector_as_f32('[0.9, 0.1, 0.0, 0.0]'), 2)"
)
.all()API
Functions
register(db: DatabaseSync): void
Source
Register the vector extension's SQL functions and virtual table modules on the given bare-sqlite connection. db must be an open DatabaseSync instance from bare-sqlite.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
db | DatabaseSync | — | An open DatabaseSync connection from bare-sqlite to register the vector functions and virtual table modules on. |
Throws
DATABASE_NOT_OPEN—dbis not open.
See also
- Bare modules — the full
bare-*catalog. - Bare runtime API — the runtime these modules extend.