Skip to main content
Version: V1.1.0

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

Request parameters

hasCollection(name: string)
ParameterTypeRequiredDescriptionExample value
namestringYesThe 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

ParameterTypeRequiredDescriptionExample value
Promise<boolean>Yestrue indicates that the collection exists. false indicates that the collection does not exist.true

Response example

true