Creates a new SQLite-backed vector store.
Inserts a document with an embedding. Generates an ID when not provided.
Parameters for the operation.
Optionaldocument?: stringRaw text content for the document.
Optionalembedding?: number[]Embedding for the document. If not provided, it will be generated based on the document.
Optionalid?: stringID for the document. If not provided, it will be auto-generated.
Optionalmetadata?: 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.
OptionalnResults?: numberNumber of top results to return.
Optionalpredicate?: (value: QueryResult) => booleanFunction to filter results after retrieval.
OptionalqueryEmbedding?: number[]Precomputed query embedding.
OptionalqueryText?: 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.
Optionaldocument?: stringNew content for the document.
Optionalembedding?: number[]New embeddings for the document. If not provided, it will be generated based on the document.
ID of the document to update.
Optionalmetadata?: 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