DocumentClient 类

定义

Provides a client-side logical representation of the Azure Cosmos DB service. This client is used to configure and execute requests against the service.

The service client encapsulates the endpoint and credentials used to access the Azure Cosmos DB service.

public class DocumentClient
继承
java.lang.Object
AutoCloseable
DocumentClient

构造函数

DocumentClient(String serviceEndpoint, List<Permission> permissionFeed, ConnectionPolicy connectionPolicy, ConsistencyLevel desiredConsistencyLevel)

Initializes a new instance of the Microsoft.Azure.Documents.Client.DocumentClient class using the specified Azure Cosmos DB service endpoint and permissions.

DocumentClient(String serviceEndpoint, List<Permission> permissionFeed, ObjectMapper objectMapper, ConnectionPolicy connectionPolicy, ConsistencyLevel desiredConsistencyLevel)

Initializes a new instance of the Microsoft.Azure.Documents.Client.DocumentClient class using the specified Azure Cosmos DB service endpoint and permissions.

DocumentClient(String serviceEndpoint, String masterKey, ConnectionPolicy connectionPolicy, ConsistencyLevel desiredConsistencyLevel)

Initializes a new instance of the DocumentClient class using the specified Azure Cosmos DB service endpoint and keys.

DocumentClient(String serviceEndpoint, String masterKey, ObjectMapper objectMapper, ConnectionPolicy connectionPolicy, ConsistencyLevel desiredConsistencyLevel)

Initializes a new instance of the DocumentClient class using the specified Azure Cosmos DB service endpoint and keys.

字段

PartitionResolverErrorMessage

方法

close()

Close this DocumentClient instance

createAttachment(String documentLink, Attachment attachment, RequestOptions options)

Creates an attachment.

createAttachment(String documentLink, InputStream mediaStream, MediaOptions options)

Creates an attachment.

createCollection(String databaseLink, DocumentCollection collection, RequestOptions options)

Creates a document collection.

createDatabase(Database database, RequestOptions options)

Creates a database.

createDocument(String collectionLink, Object document, RequestOptions options, boolean disableAutomaticIdGeneration)

Creates a document.

createPermission(String userLink, Permission permission, RequestOptions options)

Creates a permission.

createStoredProcedure(String collectionLink, StoredProcedure storedProcedure, RequestOptions options)

Creates a stored procedure.

createTrigger(String collectionLink, Trigger trigger, RequestOptions options)

Creates a trigger.

createUser(String databaseLink, User user, RequestOptions options)

Creates a user.

createUserDefinedFunction(String collectionLink, UserDefinedFunction udf, RequestOptions options)

Creates a user defined function.

deleteAttachment(String attachmentLink, RequestOptions options)

Deletes an attachment.

deleteCollection(String collectionLink, RequestOptions options)

Deletes a document collection by the collection link.

deleteConflict(String conflictLink, RequestOptions options)

Deletes a conflict.

deleteDatabase(String databaseLink, RequestOptions options)

Deletes a database.

deleteDocument(String documentLink, RequestOptions options)

Deletes a document by the document link.

deletePermission(String permissionLink, RequestOptions options)

Deletes a permission.

deleteStoredProcedure(String storedProcedureLink, RequestOptions options)

Deletes a stored procedure by the stored procedure link.

deleteTrigger(String triggerLink, RequestOptions options)

Deletes a trigger.

deleteUser(String userLink, RequestOptions options)

Deletes a user.

deleteUserDefinedFunction(String udfLink, RequestOptions options)

Deletes a user defined function.

executeStoredProcedure(String storedProcedureLink, Object[] procedureParams)

Executes a stored procedure by the stored procedure link.

executeStoredProcedure(String storedProcedureLink, RequestOptions options, Object[] procedureParams)

Executes a stored procedure by the stored procedure link.

getConnectionPolicy()
getDatabaseAccount()

Gets database account information.

getPartitionResolver(String databaseLink)
getReadEndpoint()

Gets the current read endpoint chosen based on availability and preference.

getServiceEndpoint()

Gets the default service endpoint as passed in by the user during construction.

getWriteEndpoint()

Gets the current write endpoint chosen based on availability and preference.

queryAggregateValues(String collectionLink, SqlQuerySpec querySpec, FeedOptions feedOptions)

Query for aggregation values in a document collection.

queryAggregateValues(String collectionLink, SqlQuerySpec querySpec, FeedOptions feedOptions, Object partitionKey)

Query for aggregation values in a document collection.

queryAggregateValues(String collectionLink, String query, FeedOptions feedOptions)

Query for aggregation values in a document collection.

queryAggregateValues(String collectionLink, String query, FeedOptions feedOptions, String partitionKey)

Query for aggregation values in a document collection.

queryAttachments(String documentLink, SqlQuerySpec querySpec, FeedOptions options)

Query for attachments.

queryAttachments(String documentLink, String query, FeedOptions options)

Query for attachments.

queryCollections(String databaseLink, SqlQuerySpec querySpec, FeedOptions options)

Query for document collections in a database.

queryCollections(String databaseLink, String query, FeedOptions options)

Query for document collections in a database.

queryConflicts(String collectionLink, SqlQuerySpec querySpec, FeedOptions options)

Query for conflicts.

queryConflicts(String collectionLink, String query, FeedOptions options)

Query for conflicts.

queryDatabases(SqlQuerySpec querySpec, FeedOptions options)

Query for databases.

queryDatabases(String query, FeedOptions options)

Query for databases.

queryDocumentChangeFeed(String collectionLink, ChangeFeedOptions changeFeedOptions)

Query for documents change feed in a document collection.

Example:

String partitionKeyRangeId = "0";   // Use client.readPartitionKeyRanges() to obtain the ranges.
String checkpointContinuation = null;
ChangeFeedOptions options = new ChangeFeedOptions();
options.setPartitionKeyRangeId(partitionKeyRangeId);
options.setRequestContinuation(checkpointContinuation);
options.setStartFromBeginning(true);
FeedResponse<Document> query = client.queryDocumentChangeFeed(coll.getSelfLink(), options);
do {
List&lt;Document&gt; docs = query.getQueryIterable().fetchNextBlock();

// Process the documents

// Checkpoint query.getResponseContinuation()

} while (query.getQueryIterator().hasNext());

queryDocuments(String collectionLink, SqlQuerySpec querySpec, FeedOptions options)

Query for documents in a document collection.

queryDocuments(String collectionLink, SqlQuerySpec querySpec, FeedOptions options, Object partitionKey)

Query for documents in a document collection.

queryDocuments(String collectionLink, String query, FeedOptions options)

Query for documents in a document collection.

queryDocuments(String collectionLink, String query, FeedOptions options, Object partitionKey)

Query for documents in a document collection with a partitionKey

queryOffers(SqlQuerySpec querySpec, FeedOptions options)

Query for offers in a database.

queryOffers(String query, FeedOptions options)

Query for offers in a database.

queryPermissions(String permissionLink, SqlQuerySpec querySpec, FeedOptions options)

Query for permissions.

queryPermissions(String userLink, String query, FeedOptions options)

Query for permissions.

queryStoredProcedures(String collectionLink, SqlQuerySpec querySpec, FeedOptions options)

Query for stored procedures in a document collection.

queryStoredProcedures(String collectionLink, String query, FeedOptions options)

Query for stored procedures in a document collection.

queryTriggers(String collectionLink, SqlQuerySpec querySpec, FeedOptions options)

Query for triggers.

queryTriggers(String collectionLink, String query, FeedOptions options)

Query for triggers.

queryUserDefinedFunctions(String collectionLink, SqlQuerySpec querySpec, FeedOptions options)

Query for user defined functions.

queryUserDefinedFunctions(String collectionLink, String query, FeedOptions options)

Query for user defined functions.

queryUsers(String databaseLink, SqlQuerySpec querySpec, FeedOptions options)

Query for users.

queryUsers(String databaseLink, String query, FeedOptions options)

Query for users.

readAttachment(String attachmentLink, RequestOptions options)

Reads an attachment.

readAttachments(String documentLink, FeedOptions options)

Reads all attachments in a document.

readCollection(String collectionLink, RequestOptions options)

Reads a document collection by the collection link.

readCollections(String databaseLink, FeedOptions options)

Reads all document collections in a database.

readConflict(String conflictLink, RequestOptions options)

Reads a conflict.

readConflicts(String collectionLink, FeedOptions options)

Reads all conflicts in a document collection.

readDatabase(String databaseLink, RequestOptions options)

Reads a database.

readDatabases(FeedOptions options)

Reads all databases.

readDocument(String documentLink, RequestOptions options)

Reads a document by the document link.

readDocuments(String collectionLink, FeedOptions options)

Reads all documents in a document collection.

readMedia(String mediaLink)

Reads a media by the media link.

readOffer(String offerLink)

Reads an offer.

readOffers(FeedOptions options)

Reads offers.

readPartitionKeyRanges(DocumentCollection documentCollection, FeedOptions options)

Reads all partition key ranges in a document collection.

Example:

FeedResponse<PartitionKeyRange> partitionKeyRanges = this.client.readPartitionKeyRanges(coll, null);
List<String> ids = new ArrayList<String>();
for (PartitionKeyRange range : partitionKeyRanges.getQueryIterable()) {
ids.add(range.getId());

}

readPartitionKeyRanges(String collectionLink, FeedOptions options)

Reads all partition key ranges in a document collection.

Example:

FeedResponse<PartitionKeyRange> partitionKeyRanges = this.client.readPartitionKeyRanges(coll, null);
List<String> ids = new ArrayList<String>();
for (PartitionKeyRange range : partitionKeyRanges.getQueryIterable()) {
ids.add(range.getId());

}

readPartitionKeyRanges(String collectionLink, String query)

Reads all partition key ranges in a document collection for a provided query.

readPermission(String permissionLink, RequestOptions options)

Reads a permission.

readPermissions(String userLink, FeedOptions options)

Reads all permissions.

readStoredProcedure(String storedProcedureLink, RequestOptions options)

Read a stored procedure by the stored procedure link.

readStoredProcedures(String collectionLink, FeedOptions options)

Reads all stored procedures in a document collection link.

readTrigger(String triggerLink, RequestOptions options)

Reads a trigger by the trigger link.

readTriggers(String collectionLink, FeedOptions options)

Reads all triggers in a document collection.

readUser(String userLink, RequestOptions options)

Reads a user.

readUserDefinedFunction(String udfLink, RequestOptions options)

Read a user defined function.

readUserDefinedFunctions(String collectionLink, FeedOptions options)

Reads all user defined functions in a document collection.

readUsers(String databaseLink, FeedOptions options)

Reads all users in a database.

registerPartitionResolver(String databaseLink, PartitionResolver partitionResolver)
replaceAttachment(Attachment attachment, RequestOptions options)

Replaces an attachment.

replaceCollection(DocumentCollection collection, RequestOptions options)

Replaces a document collection.

replaceDocument(Document document, RequestOptions options)

Replaces a document with the passed in document.

replaceDocument(String documentLink, Object document, RequestOptions options)

Replaces a document using a POJO object.

replaceOffer(Offer offer)

Replaces an offer.

replacePermission(Permission permission, RequestOptions options)

Replaces a permission.

replaceStoredProcedure(StoredProcedure storedProcedure, RequestOptions options)

Replaces a stored procedure.

replaceTrigger(Trigger trigger, RequestOptions options)

Replaces a trigger.

replaceUser(User user, RequestOptions options)

Replaces a user.

replaceUserDefinedFunction(UserDefinedFunction udf, RequestOptions options)

Replaces a user defined function.

updateMedia(String mediaLink, InputStream mediaStream, MediaOptions options)

Updates a media by the media link.

upsertAttachment(String documentLink, Attachment attachment, RequestOptions options)

Upserts an attachment.

upsertAttachment(String documentLink, InputStream mediaStream, MediaOptions options)

Upserts an attachment to the media stream

upsertDocument(String collectionLink, Object document, RequestOptions options, boolean disableAutomaticIdGeneration)

Upserts a document.

upsertPermission(String userLink, Permission permission, RequestOptions options)

Upserts a permission.

upsertStoredProcedure(String collectionLink, StoredProcedure storedProcedure, RequestOptions options)

Upserts a stored procedure.

upsertTrigger(String collectionLink, Trigger trigger, RequestOptions options)

Upserts a trigger.

upsertUser(String databaseLink, User user, RequestOptions options)

Upserts a user.

upsertUserDefinedFunction(String collectionLink, UserDefinedFunction udf, RequestOptions options)

Upserts a user defined function.

适用于