Internal Use Db.admin to obtain an instance of this class.
Private Readonly #dbPrivate Readonly #httpThis temporary error-ing property exists for migration convenience, and will be removed in a future version.
namespace terminology has been removed, and replaced with keyspace throughout the client.This temporary error-ing property exists for migration convenience, and will be removed in a future version.
namespace terminology has been removed, and replaced with keyspace throughout the client.Internal internalThis temporary error-ing property exists for migration convenience, and will be removed in a future version.
namespace terminology has been removed, and replaced with keyspace throughout the client.Protected _getCreates a new, additional, keyspace for this database.
NB. The operation will always wait for the operation to complete, regardless of the AstraAdminBlockingOptions. Expect it to take roughly 8-10 seconds.
The name of the new keyspace.
Optional options: CreateDataAPIKeyspaceOptionsThe options for the timeout & replication behavior of the operation.
A promise that resolves when the operation completes.
await dbAdmin.createKeyspace('my_keyspace');
await dbAdmin.createKeyspace('my_keyspace', {
replication: {
class: 'SimpleStrategy',
replicationFactor: 3,
},
});
await dbAdmin.createKeyspace('my_keyspace', {
replication: {
class: 'NetworkTopologyStrategy',
datacenter1: 3,
datacenter2: 2,
},
});
Gets the underlying Db object. The options for the db were set when the DataAPIDbAdmin instance, or whatever
spawned it, was created.
The underlying Db object.
const dbAdmin = client.admin().dbAdmin('<endpoint>', {
keyspace: 'my_keyspace',
useHttp2: false,
});
const db = dbAdmin.db();
console.log(db.keyspace);
Drops a keyspace from this database.
NB. The operation will always wait for the operation to complete, regardless of the AstraAdminBlockingOptions. Expect it to take roughly 8-10 seconds.
The name of the keyspace to drop.
Optional options: WithTimeout<"keyspaceAdminTimeoutMs">The options for the timeout of the operation.
A promise that resolves when the operation completes.
// ['default_keyspace', 'my_other_keyspace']
console.log(await dbAdmin.listKeyspaces());
await dbAdmin.dropKeyspace('my_other_keyspace');
// ['default_keyspace', 'my_other_keyspace']
console.log(await dbAdmin.listKeyspaces());
Returns detailed information about the availability and usage of the vectorize embedding providers available on the current database (may vary based on cloud provider & region).
Optional options: WithTimeout<"databaseAdminTimeoutMs">The options for the timeout of the operation.
The available embedding providers.
const { embeddingProviders } = await dbAdmin.findEmbeddingProviders();
// ['text-embedding-3-small', 'text-embedding-3-large', 'text-embedding-ada-002']
console.log(embeddingProviders['openai'].models.map(m => m.name));
Returns detailed information about the availability and usage of the reranking providers available on the current database (may vary based on cloud provider & region).
Optional options: WithTimeout<"databaseAdminTimeoutMs">The options for the timeout of the operation.
The available reranking providers.
const { rerankingProviders } = await dbAdmin.findRerankingProviders();
// ['nvidia/llama-3.2-nv-rerankqa-1b-v2']
console.log(rerankingProviders['nvidia'].models.map(m => m.name));
Lists the keyspaces in the database.
The first element in the returned array is the default keyspace of the database, and the rest are additional keyspaces in no particular order.
Optional options: WithTimeout<"keyspaceAdminTimeoutMs">A promise that resolves to list of all the keyspaces in the database.
const keyspaces = await dbAdmin.listKeyspaces();
// ['default_keyspace', 'my_other_keyspace']
console.log(keyspaces);
Unsubscribe from an event.
The event to unsubscribe from.
The listener to remove.
Subscribe to an event.
The event to listen for.
The callback to invoke when the event is emitted.
A function to unsubscribe the listener.
Subscribe to an event once.
The listener will be automatically unsubscribed after the first time it is called.
Note that the listener will be unsubscribed BEFORE the actual listener callback is invoked.
The event to listen for.
The callback to invoke when the event is emitted.
A function to prematurely unsubscribe the listener.
Remove all listeners for an event.
If no event is provided, all listeners for all events will be removed.
Optional eventName: EThe event to remove listeners for.
An administrative class for managing non-Astra databases, including creating, listing, and deleting keyspaces.
Shouldn't be instantiated directly; use Db.admin to obtain an instance of this class.
Note that the
environmentparameter MUST match the one used in theDataAPIClientoptions.Example
See