Internal Use Db.admin or AstraAdmin.dbAdmin to obtain an instance of this class.
Private Readonly #dataPrivate Readonly #dbPrivate Readonly #environmentPrivate 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.Gets the ID of the Astra DB instance this object is managing.
The ID of the Astra DB instance.
Private #infoProtected _getCreates a new, additional, keyspace for this database.
NB. this is a "long-running" operation. See AstraAdminBlockingOptions about such blocking operations. The default polling interval is 1 second. Expect it to take roughly 8-10 seconds to complete.
The name of the new keyspace.
Optional options: CreateAstraKeyspaceOptionsThe options for the blocking behavior of the operation.
A promise that resolves when the operation completes.
await dbAdmin.createKeyspace('my_other_keyspace1');
// ['default_keyspace', 'my_other_keyspace1']
console.log(await dbAdmin.listKeyspaces());
await dbAdmin.createKeyspace('my_other_keyspace2', {
blocking: false,
});
// Will not include 'my_other_keyspace2' until the operation completes
console.log(await dbAdmin.listKeyspaces());
Note that if you choose not to block, the created keyspace will not be able to be used until the operation completes, which is up to the caller to determine.
Gets the underlying Db object. The options for the db were set when the AstraDbAdmin 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.id);
Drops the database.
NB. this is a long-running operation. See AstraAdminBlockingOptions about such blocking operations. The default polling interval is 10 seconds. Expect it to take roughly 6-7 min to complete.
The database info will still be accessible by ID, or by using the AstraAdmin.listDatabases method with the filter
set to 'ALL' or 'TERMINATED'. However, all of its data will very much be lost.
Optional options: DropAstraKeyspaceOptionsThe options for the blocking behavior of the operation.
A promise that resolves when the operation completes.
const db = client.db('https://<db_id>-<region>.apps.astra.datastax.com');
await db.admin().drop();
Use with caution. Use a surge protector. Don't say I didn't warn you.
Drops a keyspace from this database.
NB. this is a "long-running" operation. See AstraAdminBlockingOptions about such blocking operations. The default polling interval is 1 second. Expect it to take roughly 8-10 seconds to complete.
The name of the keyspace to drop.
Optional options: DropAstraKeyspaceOptionsThe options for the blocking behavior of the operation.
A promise that resolves when the operation completes.
await dbAdmin.dropKeyspace('my_other_keyspace1');
// ['default_keyspace', 'my_other_keyspace2']
console.log(await dbAdmin.listKeyspaces());
await dbAdmin.dropKeyspace('my_other_keyspace2', {
blocking: false,
});
// Will still include 'my_other_keyspace2' until the operation completes
// ['default_keyspace', 'my_other_keyspace2']
console.log(await dbAdmin.listKeyspaces());
Note that if you choose not to block, the keyspace will still be able to be used until the operation completes, which is up to the caller to determine.
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));
Fetches the complete information about the database, such as the database name, IDs, region, status, actions, and other metadata.
The method issues a request to the DevOps API each time it is invoked, without caching mechanisms; this ensures up-to-date information for usages such as real-time collections validation by the application.
Optional options: WithTimeout<"databaseAdminTimeoutMs">A promise that resolves to the complete database information.
const info = await dbAdmin.info();
console.log(info.info.name, info.creationTime);
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 Astra databases, including creating, listing, and deleting keyspaces.
Shouldn't be instantiated directly; use Db.admin or AstraDbAdmin.dbAdmin to obtain an instance of this class.
To manage databases as a whole, see AstraAdmin.
Example
See