Database class

Operations for reading or deleting an existing database.

Constructors

Database(CosmosClient, string, ClientContext)

Returns a new <xref:Database> instance. Note: the intention is to get this object from <xref:CosmosClient> via client.database(id), not to instantiate it yourself.

Properties

client
containers

Used for creating new containers, or querying/reading all containers. Use .container(id) to read, replace, or delete a specific, existing <xref:Database> by id.

id
url

Returns a reference URL to the resource. Used for linking in Permissions.

users

Used for creating new users, or querying/reading all users. Use .user(id) to read, replace, or delete a specific, existing <xref:User> by id.

Methods

container(string)

Used to read, replace, or delete a specific, existing <xref:Database> by id. Use .containers creating new containers, or querying/reading all containers.

delete(RequestOptions)

Delete the given Database.

read(RequestOptions)

Read the definition of the given Database.

user(string)

Used to read, replace, or delete a specific, existing <xref:User> by id. Use .users for creating new users, or querying/reading all users.

Constructor Details

Database(CosmosClient, string, ClientContext)

Returns a new <xref:Database> instance. Note: the intention is to get this object from <xref:CosmosClient> via client.database(id), not to instantiate it yourself.

new Database(client: CosmosClient, id: string, clientContext: ClientContext)

Parameters

client
CosmosClient
id
string
clientContext
ClientContext

Property Details

client

client: CosmosClient

Property Value

containers

Used for creating new containers, or querying/reading all containers. Use .container(id) to read, replace, or delete a specific, existing <xref:Database> by id.

containers: Containers

Property Value

id

id: string

Property Value

string

url

Returns a reference URL to the resource. Used for linking in Permissions.

url: string

Property Value

string

users

Used for creating new users, or querying/reading all users. Use .user(id) to read, replace, or delete a specific, existing <xref:User> by id.

users: Users

Property Value

Method Details

container(string)

Used to read, replace, or delete a specific, existing <xref:Database> by id. Use .containers creating new containers, or querying/reading all containers.

function container(id: string)

Parameters

id
string

Returns

delete(RequestOptions)

Delete the given Database.

function delete(options?: RequestOptions)

Parameters

options
RequestOptions

Returns

Promise<DatabaseResponse>

read(RequestOptions)

Read the definition of the given Database.

function read(options?: RequestOptions)

Parameters

options
RequestOptions

Returns

Promise<DatabaseResponse>

user(string)

Used to read, replace, or delete a specific, existing <xref:User> by id. Use .users for creating new users, or querying/reading all users.

function user(id: string)

Parameters

id
string

Returns