delete - Delete data
The delete() method is used to delete records from a collection. You can delete records by ID, metadata filter, or document filter.
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 seekdb server mode. For more information, see Deploy seekdb by using yum install.
-
You are connected to the database. For more information, see SeekdbClient.
-
The user to which you are connected has the
DELETEprivilege on the table to be operated. For more information about viewing 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 directly granting privileges, see Directly grant privileges.
Request parameters
delete(
ids: ids,
where=Metadata,
whereDocument=documents,
)
| Parameter | Type | Required | Description | Example Value |
|---|---|---|---|---|
ids | string | string[] | No | The ID to be deleted. It can be a single ID or an array of IDs. | item1 |
where | Where | No | Metadata filter | {category: {$eq: "AI" }} |
whereDocument | WhereDocument | No | Document filter | { $contains: "obsolete" } |
At least one of the ids, where, or whereDocument parameters must be provided.
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.delete({
ids: "item1"
});
await collection.delete({ where: { category: { $eq: "AI" } } });
await collection.delete({ whereDocument: { $contains: "obsolete" } });
Response parameters
None