Skip to main content
Version: V1.1.0

update - Update data

The update() method is used to update existing records in a collection. When updating a record, the record must exist; otherwise, an error will be returned.

info

This API can only be used when connected with SeekdbClient. For more information about SeekdbClient, see SeekdbClient.

Prerequisites

  • You have installed seekdb-js. For more information, see Quick start.

  • You have installed the server mode of seekdb. For more information, see Deploy seekdb by using yum install.

  • You have connected to the database. For more information, see SeekdbClient.

  • The user to which you are connected has the UPDATE privilege on the table to be operated. For more information about how to view the current user privileges, see View user privileges. If the user does not have this privilege, contact the administrator to grant it. For more information about how to directly grant privileges, see Directly grant privileges.

Request parameters

update(
ids: ids,
embeddings: embeddings,
documents: documents,
metadatas: metadatas
)
ParameterTypeRequiredDescriptionExample value
idsstring | string[]YesThe ID to be modified. It can be a single ID or an array of IDs.item1
embeddingsnumber[] | number[][]NoIt can be a single vector or an array of vectors. If not provided and documents are provided, the embeddingFunction will be used to generate it.[[0.9, 0.8, 0.7], [0.6, 0.5, 0.4]]
documentsstring | string[]NoThe document content, which can be a single string or an array of strings."New document text"
metadatasMetadata | Metadata[]NoThe metadata, which can be a single object or an array of objects.{"category": "AI"}
info
  • At least one of embeddings, metadatas, or documents must be provided.
  • Only metadata can be updated (no vectors or documents). The embeddingFunction used is the one associated with the collection.
  • The length of all array parameters must be the same as the length of the ids array.
  • Only existing records are updated. Non-existent IDs are ignored.

Request example

import { SeekdbClient } from "seekdb";

const client = new SeekdbClient({
host: "127.0.0.1",
port: 2881,
user: "root",
password: "",
database: "test",
});

const collection = await client.getCollection({
name: "my_collection"
});

await collection.update({
ids: "item1",
documents: "New document text",
metadatas: { category: "AI" }
});

Response parameters

None