Interface WithKeyspace

Allows you to override the keyspace to use for some db operation. If not specified, the db operation will use either the keyspace provided when creating the Db instance, the keyspace provided when creating the DataAPIClient instance, or the default keyspace 'default_keyspace'. (in that order)

Example

const client = new DataAPIClient('AstraCS:...');

// Using 'default_keyspace' as the keyspace
const db1 = client.db('https://<db_id>-<region>.apps.astra.datastax.com');

// Using 'my_keyspace' as the keyspace
const db2 = client.db('https://<db_id>-<region>.apps.astra.datastax.com', {
  keyspace: 'my_keyspace',
});

// Finds 'my_collection' in 'default_keyspace'
const coll1 = db1.collection('my_collection');

// Finds 'my_collection' in 'my_keyspace'
const coll2 = db1.collection('my_collection', {
  keyspace: 'my_keyspace',
});

Field

keyspace - The keyspace to use for the db operation.

interface WithKeyspace {
    keyspace?: string;
    namespace?: string;
}

Hierarchy (view full)

Properties

keyspace?: string

The keyspace to use for the operation.

namespace?: string

The keyspace to use for the operation.

This is now a deprecated alias for the strictly equivalent WithKeyspace.keyspace, and will be removed in an upcoming major version.

https://docs.datastax.com/en/astra-db-serverless/api-reference/client-versions.html#version-1-5

Deprecated