hasCollection - Check collections
hasCollection() is used to check whether a specified collection exists in the database.
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.
Request parameters
hasCollection(name: string)
| Parameter | Type | Required | Description | Example value |
|---|---|---|---|---|
name | string | Yes | The name of the collection to be checked. | my_collection |
Request example
import { SeekdbClient } from "seekdb";
// 1. Connect
const client = new SeekdbClient({
host: "127.0.0.1",
port: 2881,
user: "root",
password: "",
database: "test",
});
const exists = await client.hasCollection('my_collection');
console.log(exists);
Response parameters
| Parameter | Type | Required | Description | Example value |
|---|---|---|---|---|
Promise<boolean> | Yes | true indicates that the collection exists. false indicates that the collection does not exist. | true |
Response example
true