CosmosDbPartitionedStorage class
Cosmos DB partitioned storage provider.
This class implements the legacy CosmosDbPartitionedStorage contract. Use CosmosDbPartitionedStorageV2 for the structured StorageV2 contract.
- Extends
-
CosmosDbPartitionedStorageInternals
Constructors
| Cosmos |
Initializes a new instance of the CosmosDbPartitionedStorage class. |
Inherited Properties
| compatibility |
Indicates whether the container uses the legacy |
| container | Cosmos DB container used for storage operations after initialization. |
| cosmos |
Options used to connect to and configure Cosmos DB storage. |
| length | The number of items in the storage. This property is not currently used. |
Methods
| delete(string[]) | Deletes legacy items and ignores missing documents. |
| read(string[]) | Reads legacy items and attaches Cosmos DB ETags as |
| write(Store |
Writes legacy items and applies |
Inherited Methods
| check |
Checks serialized data for nesting beyond the Cosmos DB limit. |
| get |
Gets the partition key used to address a document. |
| initialize() | Initializes the Cosmos DB container. |
| is |
Determines whether a stored item has passed its expiration time. |
Constructor Details
CosmosDbPartitionedStorage(CosmosDbPartitionedStorageOptions)
Initializes a new instance of the CosmosDbPartitionedStorage class.
new CosmosDbPartitionedStorage(cosmosDbStorageOptions: CosmosDbPartitionedStorageOptions)
Parameters
- cosmosDbStorageOptions
- CosmosDbPartitionedStorageOptions
The options for configuring Cosmos DB partitioned storage.
Inherited Property Details
compatibilityModePartitionKey
Indicates whether the container uses the legacy /_partitionKey partition key.
compatibilityModePartitionKey: boolean
Property Value
boolean
Inherited From CosmosDbPartitionedStorageInternals.compatibilityModePartitionKey
container
Cosmos DB container used for storage operations after initialization.
container: Container
Property Value
Inherited From CosmosDbPartitionedStorageInternals.container
cosmosDbStorageOptions
Options used to connect to and configure Cosmos DB storage.
cosmosDbStorageOptions: CosmosDbPartitionedStorageOptions
Property Value
Inherited From CosmosDbPartitionedStorageInternals.cosmosDbStorageOptions
length
The number of items in the storage. This property is not currently used.
length: number
Property Value
number
Inherited From CosmosDbPartitionedStorageInternals.length
Method Details
delete(string[])
Deletes legacy items and ignores missing documents.
function delete(keys: string[]): Promise<void>
Parameters
- keys
-
string[]
The keys to delete.
Returns
Promise<void>
read(string[])
Reads legacy items and attaches Cosmos DB ETags as eTag values.
function read(keys: string[]): Promise<StoreItems>
Parameters
- keys
-
string[]
The keys to read.
Returns
Promise<StoreItems>
The stored items; missing keys are omitted.
write(StoreItems)
Writes legacy items and applies eTag concurrency checks.
function write(changes: StoreItems): Promise<void>
Parameters
- changes
- StoreItems
The keyed legacy items to write.
Returns
Promise<void>
Inherited Method Details
checkForNestingError(object, string | Error | Record<"message", string>)
Checks serialized data for nesting beyond the Cosmos DB limit.
function checkForNestingError(json: object, err: string | Error | Record<"message", string>)
Parameters
- json
-
object
The data being written.
- err
-
string | Error | Record<"message", string>
The serialization or storage error that triggered the check.
Inherited From CosmosDbPartitionedStorageInternals.checkForNestingError
getPartitionKey(string)
Gets the partition key used to address a document.
function getPartitionKey(key: string): string | undefined
Parameters
- key
-
string
The escaped document key.
Returns
string | undefined
The document key, or undefined for legacy compatibility containers.
Inherited From CosmosDbPartitionedStorageInternals.getPartitionKey
initialize()
Initializes the Cosmos DB container.
function initialize(): Promise<void>
Returns
Promise<void>
Inherited From CosmosDbPartitionedStorageInternals.initialize
isExpired(DocumentStoreItem)
Determines whether a stored item has passed its expiration time.
function isExpired(item: DocumentStoreItem): boolean
Parameters
- item
-
DocumentStoreItem
The item to inspect.
Returns
boolean
true when the item has expired; otherwise, false.
Inherited From CosmosDbPartitionedStorageInternals.isExpired