Class DbAdminAbstract

Represents some DatabaseAdmin class used for managing some specific database.

This abstract version lists the core functionalities that any database admin class may have, but subclasses may have additional methods or properties (e.g. AstraDbAdmin).

Use Db.admin or AstraAdmin.dbAdmin to obtain an instance of this class.

Hierarchy (view full)

Constructors

Methods

  • Creates a new, additional, namespace (aka keyspace) for this database.

    NB. this is a "long-running" operation. See AdminBlockingOptions about such blocking operations. The default polling interval is 1 second. Expect it to take roughly 8-10 seconds to complete.

    Parameters

    • namespace: string

      The name of the new namespace.

    • Optional options: CreateNamespaceOptions

      The options for the blocking behavior of the operation.

    Returns Promise<void>

    A promise that resolves when the operation completes.

    Example

    await dbAdmin.createNamespace('my_other_keyspace1');

    // ['default_keyspace', 'my_other_keyspace1']
    console.log(await dbAdmin.listNamespaces());

    await dbAdmin.createNamespace('my_other_keyspace2', {
      blocking: false,
    });

    // Will not include 'my_other_keyspace2' until the operation completes
    console.log(await dbAdmin.listNamespaces());

    Remarks

    Note that if you choose not to block, the created namespace 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 DbAdmin instance, or whatever spawned it, was created.

    Returns Db

    The underlying Db object.

    Example

    const dbAdmin = client.admin().dbAdmin('<endpoint>', {
      namespace: 'my-namespace',
      useHttp2: false,
    });

    const db = dbAdmin.db();
    console.log(db.id);
  • Drops a namespace (aka keyspace) from this database.

    NB. this is a "long-running" operation. See AdminBlockingOptions about such blocking operations. The default polling interval is 1 second. Expect it to take roughly 8-10 seconds to complete.

    Parameters

    • namespace: string

      The name of the namespace to drop.

    • Optional options: AdminBlockingOptions

      The options for the blocking behavior of the operation.

    Returns Promise<void>

    A promise that resolves when the operation completes.

    Example

    await dbAdmin.dropNamespace('my_other_keyspace1');

    // ['default_keyspace', 'my_other_keyspace2']
    console.log(await dbAdmin.listNamespaces());

    await dbAdmin.dropNamespace('my_other_keyspace2', {
      blocking: false,
    });

    // Will still include 'my_other_keyspace2' until the operation completes
    // ['default_keyspace', 'my_other_keyspace2']
    console.log(await dbAdmin.listNamespaces());

    Remarks

    Note that if you choose not to block, the namespace 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).

    Parameters

    • Optional options: WithTimeout

      The options for the timeout of the operation.

    Returns Promise<FindEmbeddingProvidersResult>

    The available embedding providers.

    Example

    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));
  • Retrieves a list of all the namespaces in the database.

    Semantic order is not guaranteed, but implementations are free to assign one. AstraDbAdmin, for example, always has the first keyspace in the array be the default one.

    Returns Promise<string[]>

    A promise that resolves to list of all the namespaces in the database.

    Example

    const namespaces = await dbAdmin.listNamespaces();

    // ['default_keyspace', 'my_other_keyspace']
    console.log(namespaces);