VectorTable is the handle returned by db.open(). It is where you add records, look them up by id or exact-match fields, and manage indexes. For ranked, query-based retrieval see Search.
Every method that returns records is typed against your metadata, and every record has the shape { id, text, metadata }.
Adding records
add() inserts records. Each record needs an id, the text to embed and full-text index, and your metadata object. The text is embedded automatically — you never pass a vector.
add() returns the table, so calls can be chained.
Looking up records
These methods do exact-match lookups (no embedding or ranking). Use them when you already know the id or want rows matching specific field values.findById()
Returns the single record with the given id, or null if none matches.
select to return only certain columns. id is always included.
findBy()
Returns records that match an exact-match filter on metadata fields. Multiple fields are combined with AND; undefined values are ignored.
| Option | Type | Default | Description |
|---|---|---|---|
limit | number | 10 | Maximum records to return. |
select | (keyof metadata | "id" | "text")[] | all columns | Columns to return; id is always included. |
findOneBy()
Like findBy() but returns the first match or null.
In
findBy() / findOneBy(), the keys are your metadata field names — the package resolves them to the underlying metadata.<field> columns for you. The same applies to select and to filters.Indexing
Tables created byopen() already carry a btree index on id, a full-text index on text, and an IVF-PQ index on vector. These methods let you add or rebuild indexes — for example a scalar index on a metadata field you filter on often.
createIndex()
Creates a scalar index on a column. Choose the index type via config: btree (range and equality), bitmap (low-cardinality categories), or labelList (list membership).
createVectorIndex()
Creates an IVF-PQ vector index. Defaults to the vector column.
Inspecting query plans
explainPlan() and analyzePlan() help you tune retrieval — they reveal which indexes are used and where time is spent. See Search → Inspecting query plans for details and examples.