CosmosDbContainer class

Class representing a CosmosDB container.

Inheritance

Constructors

CosmosDbContainer(CosmosDbDatabase database, String id, {PartitionKeySpec? partitionKeySpec, IndexingPolicy? indexingPolicy, GeospatialConfig? geospatialConfig})

Properties

database CosmosDbDatabase
The container's parent CosmosDbDatabase.
final
exists bool?
Flag indicating whether the container exists in CosmosDB. null if no check has been made yet.
no setter
geospatialConfig GeospatialConfig?
The container's geospatial configuration.
no setter
hashCode int
The hash code for this object.
no setterinherited
id String
The document's id.
final
indexingPolicy IndexingPolicy?
The container's indexing policy.
no setter
onForbidden FutureCallback<CosmosDbPermission?>?
Callback to refresh a permission. When the container-wide CosmosDbPermission expires and a CosmosDB API replies with a ForbiddenException (HTTP error 403), this callback will be invoked to obtain a new, valid CosmosDbPermission that will replace the expired one.
getter/setter pair
partitionKeySpec PartitionKeySpec
The container's partition key specification.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
url String
The container's base url.
final

Methods

add<T extends BaseDocument>(T document, {PartitionKey? partitionKey, CosmosDbPermission? permission}) Future<T>
Adds a new document to this container.
clearPermission() → void
Clear the container-wide permission.
delete<T extends BaseDocument>({String? id, T? document, bool throwOnNotFound = false, bool checkEtag = true, PartitionKey? partitionKey, CosmosDbPermission? permission}) Future<bool>
Deletes the document from this container. If the document does not exist, this method returns true by default. If throwOnNotFound is set to true, it will instead throw a NotFoundException. If the document is provided, its attributes take over the id value. If it has EtagMixin, its EtagMixin.etag must be known.
execute(TransactionalBatch batch, {CosmosDbPermission? permission}) Future<BatchResponse>
Executes the batch in this container.
find<T extends BaseDocument>(dynamic id, PartitionKey partitionKey, {bool throwOnNotFound = false, CosmosDbPermission? permission}) Future<T?>
Finds the document with id in this container. If the document does not exist, this method returns null by default. If throwOnNotFound is set to true, it will throw a NotFoundException instead.
get<T extends BaseDocument>(T document, {bool throwOnNotFound = false, PartitionKey? partitionKey, CosmosDbPermission? permission}) Future<T?>
Returns the latest version of the document.
getInfo({CosmosDbPermission? permission}) Future<CosmosDbContainer>
Gets information for this CosmosDbContainer.
getPkRanges({CosmosDbPermission? permission, bool force = false}) Future<Iterable<PartitionKeyRange>>
Gets the partition key ranges for this CosmosDbContainer.
list<T extends BaseDocument>({PartitionKey? partitionKey, CosmosDbPermission? permission}) Future<Iterable<T>>
Lists all documents from this container.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
patch<T extends BaseDocument>(T document, Patch patch, {PartitionKey? partitionKey, CosmosDbPermission? permission}) Future<T>
Updates (patches) a document in this container by applying the patch operations.
prepareAtomicBatch({PartitionKey? partitionKey}) Batch
Prepare a batch for this container (atomic).
prepareBatch({PartitionKey? partitionKey, bool continueOnError = true}) Batch
Prepare a batch for this container.
prepareCrossPartitionBatch({PartitionKey? partitionKey}) Batch
Prepare a batch for this container (cross-partition).
query<T extends BaseDocument>(Query query, {CosmosDbPermission? permission}) Future<Iterable<T>>
Loads documents from this container matching the provided query.
rawQuery(Query query, {CosmosDbPermission? permission}) Future
Loads documents from this container matching the provided query.
registerBuilder<T extends BaseDocument>(DocumentBuilder<T> builder) → void
Register a DocumentBuilder for specified type T.
replace<T extends BaseDocument>(T document, {bool checkEtag = true, PartitionKey? partitionKey, CosmosDbPermission? permission}) Future<T>
Updates (replaces) a document in this container. If the document has EtagMixin, its EtagMixin.etag must be known.
setIndexingPolicy(IndexingPolicy indexingPolicy, {GeospatialConfig? geospatialConfig, CosmosDbPermission? permission}) Future<void>
Gets information for this CosmosDbContainer.
toJson() Map<String, dynamic>
Serializes this instance to a JSON object.
override
toString() String
A string representation of this object.
inherited
upsert<T extends BaseDocument>(T document, {PartitionKey? partitionKey, CosmosDbPermission? permission}) Future<T>
Adds or updates (replaces) a document in this container.
usePermission(CosmosDbPermission permission) → void
Use this CosmosDbPermission when invoking the CosmosDB API. Using CosmosDbPermission is a way to avoid disclosing the master key in client applications; to retrieve or create a permission, you should implement some additional API to be used by your client app. This API will protect your master keys. Most methods from CosmosDbContainer support an optional permission argument, to allow for overriding this container-wide permission.

Operators

operator ==(Object other) bool
The equality operator.
inherited