pub struct DatabaseClient { /* private fields */ }
Expand description
A client for working with a specific database in a Cosmos DB account.
You can get a DatabaseClient
by calling CosmosClient::database_client()
.
Implementations§
Source§impl DatabaseClient
impl DatabaseClient
Sourcepub fn container_client(&self, name: &str) -> ContainerClient
pub fn container_client(&self, name: &str) -> ContainerClient
Gets a ContainerClient
that can be used to access the collection with the specified name.
§Arguments
name
- The name of the container.
Sourcepub async fn read(
&self,
options: Option<ReadDatabaseOptions<'_>>,
) -> Result<Response<DatabaseProperties>>
pub async fn read( &self, options: Option<ReadDatabaseOptions<'_>>, ) -> Result<Response<DatabaseProperties>>
Sourcepub fn query_containers(
&self,
query: impl Into<Query>,
options: Option<QueryContainersOptions<'_>>,
) -> Result<FeedPager<ContainerProperties>>
pub fn query_containers( &self, query: impl Into<Query>, options: Option<QueryContainersOptions<'_>>, ) -> Result<FeedPager<ContainerProperties>>
Executes a query against containers in the database.
§Arguments
query
- The query to execute.options
- Optional parameters for the request.
§Examples
The query
parameter accepts anything that can be transformed Into
a Query
.
This allows simple queries without parameters to be expressed easily:
let containers = db_client.query_containers(
"SELECT * FROM dbs",
None)?;
See Query
for more information on how to specify a query.
Sourcepub async fn create_container(
&self,
properties: ContainerProperties,
options: Option<CreateContainerOptions<'_>>,
) -> Result<Response<ContainerProperties>>
pub async fn create_container( &self, properties: ContainerProperties, options: Option<CreateContainerOptions<'_>>, ) -> Result<Response<ContainerProperties>>
Creates a new container.
This is a control-plane API and requires that you authenticate using a key. To use Entra ID to perform this operation, you must use the Azure Resource Manager APIs.
§Arguments
properties
- AContainerProperties
describing the new container.options
- Optional parameters for the request.
Sourcepub async fn delete(
&self,
options: Option<DeleteDatabaseOptions<'_>>,
) -> Result<Response<()>>
pub async fn delete( &self, options: Option<DeleteDatabaseOptions<'_>>, ) -> Result<Response<()>>
Deletes this database.
This is a control-plane API and requires that you authenticate using a key. To use Entra ID to perform this operation, you must use the Azure Resource Manager APIs.
§Arguments
options
- Optional parameters for the request.
Sourcepub async fn read_throughput(
&self,
options: Option<ThroughputOptions<'_>>,
) -> Result<Option<Response<ThroughputProperties>>>
pub async fn read_throughput( &self, options: Option<ThroughputOptions<'_>>, ) -> Result<Option<Response<ThroughputProperties>>>
Reads database throughput properties, if any.
This will return None
if the database does not have a throughput offer configured.
§Arguments
options
- Optional parameters for the request.
Sourcepub async fn replace_throughput(
&self,
throughput: ThroughputProperties,
options: Option<ThroughputOptions<'_>>,
) -> Result<Response<ThroughputProperties>>
pub async fn replace_throughput( &self, throughput: ThroughputProperties, options: Option<ThroughputOptions<'_>>, ) -> Result<Response<ThroughputProperties>>
Replaces the database throughput properties.
§Arguments
throughput
- The new throughput properties to set.options
- Optional parameters for the request.