CosmosDbPartitionedStorageV2 class

A Cosmos DB provider for the structured CosmosDbPartitionedStorageV2 contract.

This is the V2 counterpart to CosmosDbPartitionedStorage and uses the same CosmosDbPartitionedStorageOptions. Each read, write, and delete returns an outcome for every requested key. Cosmos DB ETags are returned as separate storage versions, and writes support create-only, replace, and expected-version conditions for optimistic concurrency.

Extends

Constructors

CosmosDbPartitionedStorageV2(CosmosDbPartitionedStorageOptions)

Creates a V2 Cosmos DB storage provider.

Methods

delete(string[], StorageDeleteOptions)

Deletes V2 items with an optional expected-version condition.

read<T>(string[])

Reads V2 items with one status and Cosmos DB ETag version per requested key.

write<T>(Record<string, T>, StorageWriteOptions)

Writes V2 items with mode and expected-version conditions.

Constructor Details

CosmosDbPartitionedStorageV2(CosmosDbPartitionedStorageOptions)

Creates a V2 Cosmos DB storage provider.

new CosmosDbPartitionedStorageV2(options: CosmosDbPartitionedStorageOptions)

Parameters

options
CosmosDbPartitionedStorageOptions

The Cosmos DB connection, database, container, and partitioning options.

Method Details

delete(string[], StorageDeleteOptions)

Deletes V2 items with an optional expected-version condition.

function delete(keys: string[], options?: StorageDeleteOptions): Promise<StorageDeleteResults>

Parameters

keys

string[]

The keys to delete.

options
StorageDeleteOptions

The optional expected version.

Returns

One keyed operation result per requested key.

read<T>(string[])

Reads V2 items with one status and Cosmos DB ETag version per requested key.

function read<T>(keys: string[]): Promise<StorageReadResults<T>>

Parameters

keys

string[]

The keys to read.

Returns

Promise<StorageReadResults<T>>

The keyed V2 read results.

write<T>(Record<string, T>, StorageWriteOptions)

Writes V2 items with mode and expected-version conditions.

function write<T>(changes: Record<string, T>, options?: StorageWriteOptions): Promise<StorageWriteResults>

Parameters

changes

Record<string, T>

The keyed values to write.

options
StorageWriteOptions

The V2 write mode and expected version.

Returns

One keyed operation result per change.