共用方式為


DocumentCollection Class

public final class DocumentCollection
extends Resource

Represents a document collection in the Azure Cosmos DB database service. A collection is a named logical container for documents.

A database may contain zero or more named collections and each collection consists of zero or more JSON documents. Being schema-free, the documents in a collection do not need to share the same structure or fields. Since collections are application resources, they can be authorized using either the master key or resource keys.

Constructor Summary

Constructor Description
DocumentCollection()

Initialize a document collection object.

DocumentCollection(String jsonString)

Initialize a document collection object from json string.

DocumentCollection(JSONObject jsonObject)

Initialize a document collection object from json object.

Method Summary

Modifier and Type Method and Description
boolean equals(Object obj)
java.util.Collection<PartitionKeyRangeStatistics> getCollectionPartitionStatistics()

Gets the collection's partition key statistics for each physical partition in the collection.

ConflictResolutionPolicy getConflictResolutionPolicy()

Gets the conflictResolutionPolicy that is used for resolving conflicting writes on documents in different regions, in a collection in the Azure Cosmos DB service.

java.lang.String getConflictsLink()

Gets the self-link for conflicts in a collection.

java.lang.Integer getDefaultTimeToLive()

Gets the collection's default time-to-live value.

java.lang.String getDocumentsLink()

Gets the self-link for documents in a collection.

IndexingPolicy getIndexingPolicy()

Gets the indexing policy.

PartitionKeyDefinition getPartitionKey()

Gets the collection's partition key definition.

java.lang.String getStoredProceduresLink()

Gets the self-link for stored procedures in a collection.

java.lang.String getTriggersLink()

Gets the self-link for triggers in a collection.

UniqueKeyPolicy getUniqueKeyPolicy()

Sets the Uni that guarantees uniqueness of documents in collection in the Azure Cosmos DB service.

java.lang.String getUserDefinedFunctionsLink()

Gets the self-link for user defined functions in a collection.

int hashCode()
void setConflictResolutionPolicy(ConflictResolutionPolicy value)

Sets the conflictResolutionPolicy that is used for resolving conflicting writes on documents in different regions, in a collection in the Azure Cosmos DB service.

void setDefaultTimeToLive(Integer timeToLive)

Sets the collection's default time-to-live value.

void setIndexingPolicy(IndexingPolicy indexingPolicy)

Sets the indexing policy.

void setPartitionKey(PartitionKeyDefinition partitionKey)

Sets the collection's partition key definition.

void setUniqueKeyPolicy(UniqueKeyPolicy uniqueKeyPolicy)

Methods inherited from JsonSerializable

Methods inherited from Resource

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Constructor Details

DocumentCollection

public DocumentCollection()

Initialize a document collection object.

DocumentCollection

public DocumentCollection(String jsonString)

Initialize a document collection object from json string.

Parameters:

jsonString - the json string that represents the document collection.

DocumentCollection

public DocumentCollection(JSONObject jsonObject)

Initialize a document collection object from json object.

Parameters:

jsonObject - the json object that represents the document collection.

Method Details

equals

public boolean equals(Object obj)

Overrides:

DocumentCollection.equals(Object obj)

Parameters:

obj

getCollectionPartitionStatistics

public Collection getCollectionPartitionStatistics()

Gets the collection's partition key statistics for each physical partition in the collection.

Returns:

the partition key statistics for each physical partition in the collection.

getConflictResolutionPolicy

public ConflictResolutionPolicy getConflictResolutionPolicy()

Gets the conflictResolutionPolicy that is used for resolving conflicting writes on documents in different regions, in a collection in the Azure Cosmos DB service.

Returns:

ConflictResolutionPolicy

getConflictsLink

public String getConflictsLink()

Gets the self-link for conflicts in a collection.

Returns:

the conflicts link.

getDefaultTimeToLive

public Integer getDefaultTimeToLive()

Gets the collection's default time-to-live value.

Returns:

the the default time-to-live value in seconds.

getDocumentsLink

public String getDocumentsLink()

Gets the self-link for documents in a collection.

Returns:

the document link.

getIndexingPolicy

public IndexingPolicy getIndexingPolicy()

Gets the indexing policy.

Returns:

the indexing policy.

getPartitionKey

public PartitionKeyDefinition getPartitionKey()

Gets the collection's partition key definition.

Returns:

the partition key definition.

getStoredProceduresLink

public String getStoredProceduresLink()

Gets the self-link for stored procedures in a collection.

Returns:

the stored procedures link.

getTriggersLink

public String getTriggersLink()

Gets the self-link for triggers in a collection.

Returns:

the trigger link.

getUniqueKeyPolicy

public UniqueKeyPolicy getUniqueKeyPolicy()

Sets the Uni that guarantees uniqueness of documents in collection in the Azure Cosmos DB service.

Returns:

UniqueKeyPolicy

getUserDefinedFunctionsLink

public String getUserDefinedFunctionsLink()

Gets the self-link for user defined functions in a collection.

Returns:

the user defined functions link.

hashCode

public int hashCode()

Overrides:

DocumentCollection.hashCode()

setConflictResolutionPolicy

public void setConflictResolutionPolicy(ConflictResolutionPolicy value)

Sets the conflictResolutionPolicy that is used for resolving conflicting writes on documents in different regions, in a collection in the Azure Cosmos DB service.

Parameters:

value - ConflictResolutionPolicy to be used.

setDefaultTimeToLive

public void setDefaultTimeToLive(Integer timeToLive)

Sets the collection's default time-to-live value.

The default time-to-live value on a collection is an optional property. If set, the documents within the collection expires after the specified number of seconds since their last write time. The value of this property should be one of the following:

null - indicates evaluation of time-to-live is disabled and documents within the collection will never expire, regardless whether individual documents have their time-to-live set.

nonzero positive integer - indicates the default time-to-live value for all documents within the collection. This value can be overridden by individual documents' time-to-live value.

-1 - indicates by default all documents within the collection never expire. This value can be overridden by individual documents' time-to-live value.

Parameters:

timeToLive - the default time-to-live value in seconds.

setIndexingPolicy

public void setIndexingPolicy(IndexingPolicy indexingPolicy)

Sets the indexing policy.

Parameters:

indexingPolicy - the indexing policy.

setPartitionKey

public void setPartitionKey(PartitionKeyDefinition partitionKey)

Sets the collection's partition key definition.

Parameters:

partitionKey - the partition key definition.

setUniqueKeyPolicy

public void setUniqueKeyPolicy(UniqueKeyPolicy uniqueKeyPolicy)

Parameters:

uniqueKeyPolicy

Applies to