use of com.azure.cosmos.models.CosmosPatchOperations in project azure-cosmos-java-sql-api-samples by Azure-Samples.
the class SamplePatchQuickstart method patchIncrement.
private void patchIncrement(String id, String partitionKey) {
logger.info("Executing Patch with 'increment' operations");
CosmosPatchOperations cosmosPatchOperations = CosmosPatchOperations.create();
cosmosPatchOperations.add("/int", 42).increment("/int", 1).increment("/int", -1).add("/float", 42).increment("/float", 4.2).increment("/float", -4.2);
CosmosPatchItemRequestOptions options = new CosmosPatchItemRequestOptions();
try {
CosmosItemResponse<Family> response = this.container.patchItem(id, new PartitionKey(partitionKey), cosmosPatchOperations, options, Family.class);
logger.info("Item with ID {} has been patched", response.getItem().getId());
} catch (Exception e) {
logger.error("failed", e);
}
}
Aggregations