update
Updates an existing vector with the provided ID.
update(
id: string,
data?: string | number[],
metadata?: Record<string, any>,
options?: {
textSplitter?: SplitterParams
}
): Promise<void>;
Reference
import { myVectorStore } from "#elements";
export default async function () {
await myVectorStore.update("1", "newText", { key: "value" });
console.log("Vector updated");
}
Parameters
id
: The ID of the vector or content string to update.data
: (Optional) The new vector or content string to replace the existing one.metadata
: (Optional) The new metadata to replace the existing one.options
: Optional configuration parameters, including:textSplitter
: (Optional) The text splitter employed to divide the content into multiple vectors. In the absence of a provided splitter, the token splitter is used by default.
Returns
Promise of the update operation. No value is returned upon successful execution.
Caveats
- If the
data
is passed as a string, it will be converted to an embedding before the update. - If you only need to update the
data
, you can set themetadata
parameter to undefined. - If you only need to update the
metadata
, you can set thedata
parameter to undefined. - If the
data
andmetadata
parameters are not provided, no changes will occur.