Creates a new SQLite-backed vector store.
Inserts a document with an embedding. Generates an ID when not provided.
Parameters for the operation.
Optional
document?: stringRaw text content for the document.
Optional
embedding?: number[]Embedding for the document. If not provided, it will be generated based on the document
.
Optional
id?: stringID for the document. If not provided, it will be auto-generated.
Optional
metadata?: Record<string, any>Metadata for the document.
Promise that resolves to the ID of the newly added document.
Drops the vectors table entirely.
Opens the database, loads embeddings, and ensures schema/indexes exist.
Promise that resolves to the same instance.
Executes a cosine-similarity query over stored vectors.
Provide exactly one of queryText
or queryEmbedding
.
Query parameters.
Optional
nResults?: numberNumber of top results to return.
Optional
predicate?: (value: QueryResult) => booleanFunction to filter results after retrieval.
Optional
queryEmbedding?: number[]Precomputed query embedding.
Optional
queryText?: stringRaw query string to search for.
Promise that resolves to an array of QueryResult.
Closes embeddings and the underlying database connection.
Promise that resolves when unloading is complete.
Updates a document by ID.
Parameters for the update.
Optional
document?: stringNew content for the document.
Optional
embedding?: number[]New embeddings for the document. If not provided, it will be generated based on the document
.
ID of the document to update.
Optional
metadata?: Record<string, any>New metadata for the document.
Promise that resolves when the update completes.
SQLite-backed implementation of VectorStore using
@op-engineering/op-sqlite
.Stores embeddings as an F32 blob and uses vector indexing helpers for efficient cosine-similarity search. Suitable for on-device retrieval in React Native apps.
Example