Data
After declaring an index, you can write and manage vector records through mutation and retrieval operations.
Vector Record
Section titled “Vector Record”Each record has an application-defined id, a values array matching the index
dimensions, and optional metadata.
interface VectorRecord { id: string values: number[] metadata?: Record<string, unknown>}Insert
Section titled “Insert”Add new vector records. Fails if a record with the same id already exists.
const result = await docs.insert({ id: "doc_1", values: [0.1, 0.2, 0.3], metadata: { tenantId: "tenant_1" },})Pass multiple records in a single call:
const result = await docs.insert([ { id: "doc_1", values: [0.1, 0.2, 0.3] }, { id: "doc_2", values: [0.4, 0.5, 0.6] },])Upsert
Section titled “Upsert”Insert or replace a vector record by id. Creates the record if it does not exist; replaces the values and metadata if it does.
const result = await docs.upsert({ id: "doc_1", values: [0.1, 0.2, 0.3], metadata: { tenantId: "tenant_1", title: "Guide" },})Read vector records by one or more ids.
const records = await docs.get("doc_1")const records = await docs.get(["doc_1", "doc_2"])Returns an array of matching VectorRecord objects.
Delete
Section titled “Delete”Remove vector records by one or more ids.
const result = await docs.delete("doc_1")const result = await docs.delete(["doc_1", "doc_2"])Returns a VectorMutationResult with the count and ids of accepted deletions.
Describe
Section titled “Describe”Return the index configuration known to Layeron: namespace, name, dimensions, metric, and binding name.
const config = await docs.describe()// { namespace: "default", name: "docs", dimensions: 768, metric: "cosine", binding: "..." }Mutation Result
Section titled “Mutation Result”Insert, upsert, and delete return a VectorMutationResult:
interface VectorMutationResult { count: number ids: string[]}Batch Constraints
Section titled “Batch Constraints”- Each call accepts 1 to 1000 vector records.
- Each record’s
valuesarray must match the index dimensions exactly.