Skip to main content
Version: V1.1.0

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.

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 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 DELETE privilege 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,
)
ParameterTypeRequiredDescriptionExample Value
idsstring | string[]NoThe ID to be deleted. It can be a single ID or an array of IDs.item1
whereWhereNoMetadata filter{category: {$eq: "AI" }}
whereDocumentWhereDocumentNoDocument filter{ $contains: "obsolete" }
info

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