Skip to content

Data

After declaring an index, you can write and manage vector records through mutation and retrieval operations.

Each record has an application-defined id, a values array matching the index dimensions, and optional metadata.

Terminal window
interface VectorRecord {
id: string
values: number[]
metadata?: Record<string, unknown>
}

Add new vector records. Fails if a record with the same id already exists.

Terminal window
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:

Terminal window
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] },
])

Insert or replace a vector record by id. Creates the record if it does not exist; replaces the values and metadata if it does.

Terminal window
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.

Terminal window
const records = await docs.get("doc_1")
Terminal window
const records = await docs.get(["doc_1", "doc_2"])

Returns an array of matching VectorRecord objects.

Remove vector records by one or more ids.

Terminal window
const result = await docs.delete("doc_1")
Terminal window
const result = await docs.delete(["doc_1", "doc_2"])

Returns a VectorMutationResult with the count and ids of accepted deletions.

Return the index configuration known to Layeron: namespace, name, dimensions, metric, and binding name.

Terminal window
const config = await docs.describe()
// { namespace: "default", name: "docs", dimensions: 768, metric: "cosine", binding: "..." }

Insert, upsert, and delete return a VectorMutationResult:

Terminal window
interface VectorMutationResult {
count: number
ids: string[]
}
  • Each call accepts 1 to 1000 vector records.
  • Each record’s values array must match the index dimensions exactly.