List keyspaces (TypeScript)
Lists all keyspaces in a database.
|
You need an application token with permission to interact with the target database, such as the Database Administrator role. For more information, see Get endpoint and token. |
Result
Returns a promise that resolves to the keyspace names as a list of strings, with the default keyspace first and the remaining keyspaces in any order.
Signature
Use the listKeyspaces method, which belongs to the DataAPIDbAdmin class.
async listKeyspaces(
options?: {
timeout?: number | TimeoutDescriptor,
}
): void
Parameters
| Name | Type | Summary |
|---|---|---|
|
|
Optional.
The options for this operation. See Properties of |
| Name | Type | Summary |
|---|---|---|
|
|
Optional. The timeout(s) to apply to this method.
You can specify For more information about the |
Examples
The following examples demonstrate how to list keyspaces.
List keyspaces
import { DataAPIClient } from "@datastax/astra-db-ts";
// Get a database
const client = new DataAPIClient();
const database = client.db("API_ENDPOINT", {
token: "APPLICATION_TOKEN",
});
// Get an admin object
const admin = database.admin();
// List keyspaces
(async function () {
const keyspaces = await admin.listKeyspaces();
console.log(keyspaces);
})();
Client reference
For more information, see the client reference.