@Beta(value=V4_11_0, warningText="Preview API - subject to change in non-backwards compatible way") public final class CosmosPatchOperations extends Object
{
a : "xyz"
b : {
c : "efg:
d : 4
e : [0, 1, 2 , 3]
}
}
Modifier and Type | Method and Description |
---|---|
<T> CosmosPatchOperations |
add(String path,
T value)
This performs one of the following functions, depending upon what the target location references:
1.
|
static CosmosPatchOperations |
create()
Initializes a new instance of
CosmosPatchOperations that will contain operations to be performed on a item atomically. |
CosmosPatchOperations |
increment(String path,
double value)
This increment the value at the target location.
|
CosmosPatchOperations |
increment(String path,
long value)
This increment the value at the target location.
|
CosmosPatchOperations |
remove(String path)
This removes the value at the target location.
|
<T> CosmosPatchOperations |
replace(String path,
T value)
This replaces the value at the target location with a new value.
|
<T> CosmosPatchOperations |
set(String path,
T value)
This sets the value at the target location with a new value.
|
@Beta(value=V4_11_0, warningText="Preview API - subject to change in non-backwards compatible way") public static CosmosPatchOperations create()
CosmosPatchOperations
that will contain operations to be performed on a item atomically.CosmosPatchOperations
.@Beta(value=V4_11_0, warningText="Preview API - subject to change in non-backwards compatible way") public <T> CosmosPatchOperations add(String path, T value)
CosmosPatchOperations cosmosPatch = CosmosPatchOperations.create();
cosmosPatch.add("/b/e", 15); // will add a value to the array, so /b/e array will become [0, 1, 2, 3, 15]
cosmosPatch.add("/a", "new value"); // will replace the value
cosmosPatch.add("/b/e/1", 10); // will change value of the /b/e array to [0, 10, 2, 3]
This operation is not idempotent for scenario 1 and 2. For 3rd it is as the final value will be the value
provided here.T
- The type of item to be added.path
- the operation path.value
- the value which will be added.CosmosPatchOperations
@Beta(value=V4_11_0, warningText="Preview API - subject to change in non-backwards compatible way") public CosmosPatchOperations remove(String path)
CosmosPatchOperations cosmosPatch = CosmosPatchOperations.create();
cosmosPatch.remove("/a");
cosmosPatch.remove("/b/e/3"); // will remove 4th element of /b/e array
This operation is not idempotent. Since once applied, next time it will return bad request due to path not found.path
- the operation path.CosmosPatchOperations
@Beta(value=V4_11_0, warningText="Preview API - subject to change in non-backwards compatible way") public <T> CosmosPatchOperations replace(String path, T value)
CosmosPatchOperations cosmosPatch = CosmosPatchOperations.create();
cosmosPatch.replace("/a", "new value"); // will replace "xyz" to "new value"
cosmosPatch.replace("/b/e/1", 2); // will replace 2nd element of /b/e array to 2
This operation is idempotent as multiple call execution replace to the same value.T
- The type of item to be replaced.path
- the operation path.value
- the value which will be replaced.CosmosPatchOperations
@Beta(value=V4_11_0, warningText="Preview API - subject to change in non-backwards compatible way") public <T> CosmosPatchOperations set(String path, T value)
CosmosPatchOperations cosmosPatch = CosmosPatchOperations.create();
cosmosPatch.set("/f", "new value"); // will add a new path "/f" and set it's value as "new value".
cosmosPatch.set("/b/e", "bar"); // will set "/b/e" path to be "bar".
This operation is idempotent as multiple execution will set the same value. If a new path is added, next time
same value will be set.T
- The type of item to be set.path
- the operation path.value
- the value which will be set.CosmosPatchOperations
@Beta(value=V4_11_0, warningText="Preview API - subject to change in non-backwards compatible way") public CosmosPatchOperations increment(String path, long value)
CosmosPatchOperations cosmosPatch = CosmosPatchOperations.create();
cosmosPatch.increment("/b/d", 1); // will add 1 to "/b/d" resulting in 5.
This is not idempotent as multiple execution will increase the value by the given increment. For multi-region
we do support concurrent increment on different regions and the final value is a merged value combining
all increments value.
However if multiple increments are on the same region, it can lead to concurrency issue which can be retried.path
- the operation path.value
- the value which will be incremented.CosmosPatchOperations
@Beta(value=V4_11_0, warningText="Preview API - subject to change in non-backwards compatible way") public CosmosPatchOperations increment(String path, double value)
CosmosPatchOperations cosmosPatch = CosmosPatchOperations.create();
cosmosPatch.increment("/b/d", 3.5); // will add 3.5 to "/b/d" resulting in 7.5.
This is not idempotent as multiple execution will increase the value by the given increment. For multi-region
we do support concurrent increment on different regions and the final value is a merged value combining
all increments values.
However if multiple increments are on the same region, it can lead to concurrency issue which can be retried.path
- the operation path.value
- the value which will be incremented.CosmosPatchOperations
Copyright © 2021 Microsoft Corporation. All rights reserved.