Class MutateInSpec
- java.lang.Object
-
- com.couchbase.client.java.kv.MutateInSpec
-
- Direct Known Subclasses:
ArrayAddUnique
,ArrayAppend
,ArrayInsert
,ArrayPrepend
,FullDocument
,Increment
,Insert
,Remove
,Replace
,Upsert
public abstract class MutateInSpec extends Object
-
-
Constructor Summary
Constructors Constructor Description MutateInSpec()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <T> ArrayAddUnique
arrayAddUnique(String path, Object value)
Creates a command with the intent of inserting a value into an existing JSON array, but only if the value is not already contained in the array (by way of string comparison).static <T> ArrayAppend
arrayAppend(String path, Object value)
Creates a command with the intention of appending a value to an existing JSON array.static <T> ArrayInsert
arrayInsert(String path, Object value)
Creates a command with the intention of inserting a value into an existing JSON array.static <T> ArrayPrepend
arrayPrepend(String path, Object value)
Creates a command with the intention of prepending a value to an existing JSON array.static <T> Increment
decrement(String path, long delta)
Creates a command with the intent of decrementing a numerical field in a JSON object.abstract SubdocMutateRequest.Command
encode(JsonSerializer defaultSerializer)
static <T> FullDocument
fullDocument(Object value)
Deprecated.this functionality has been deprecated and will be removed in a future release.static <T> Increment
increment(String path, long delta)
Creates a command with the intent of incrementing a numerical field in a JSON object.static <T> Insert
insert(String path, Object value)
Creates a command with the intention of inserting a new value in a JSON object.static <T> Remove
remove(String path)
Creates a command with the intention of removing an existing value in a JSON object.static <T> Replace
replace(String path, Object value)
Creates a command with the intention of replacing an existing value in a JSON object.static <T> Upsert
upsert(String path, Object value)
Creates a command with the intention of upserting a value in a JSON object.
-
-
-
Method Detail
-
encode
@Internal public abstract SubdocMutateRequest.Command encode(JsonSerializer defaultSerializer)
-
replace
public static <T> Replace replace(String path, Object value)
Creates a command with the intention of replacing an existing value in a JSON object.Will error if the last element of the path does not exist.
- Parameters:
path
- the path identifying where to replace the value.value
- the value to replace with
-
insert
public static <T> Insert insert(String path, Object value)
Creates a command with the intention of inserting a new value in a JSON object.Will error if the last element of the path already exists.
- Parameters:
path
- the path identifying where to insert the value.value
- the value to insert
-
remove
public static <T> Remove remove(String path)
Creates a command with the intention of removing an existing value in a JSON object.Will error if the path does not exist.
- Parameters:
path
- the path identifying what to remove
-
upsert
public static <T> Upsert upsert(String path, Object value)
Creates a command with the intention of upserting a value in a JSON object.That is, the value will be replaced if the path already exists, or inserted if not.
If the path is empty (""), then the value will be used for the document's full body. Whether the document is to be upserted or inserted is controlled by
MutateInOptions.upsertDocument(boolean)
andMutateInOptions.insertDocument(boolean)
.- Parameters:
path
- the path identifying where to upsert the value.value
- the value to upsert
-
fullDocument
@Deprecated @Internal public static <T> FullDocument fullDocument(Object value)
Deprecated.this functionality has been deprecated and will be removed in a future release. Instead, specify a blank path ("") on an upsert commandCreates a command with the intention of upserting the full body of a JSON document.Provided to support advanced workflows that need to set a document's extended attributes (xattrs) at the same time as the document's regular content.
- Parameters:
value
- the value to upsert to the document's body
-
arrayAppend
public static <T> ArrayAppend arrayAppend(String path, Object value)
Creates a command with the intention of appending a value to an existing JSON array.Will error if the last element of the path does not exist or is not an array.
- Parameters:
path
- the path identifying an array to which to append the value.value
- the value to append
-
arrayPrepend
public static <T> ArrayPrepend arrayPrepend(String path, Object value)
Creates a command with the intention of prepending a value to an existing JSON array.Will error if the last element of the path does not exist or is not an array.
- Parameters:
path
- the path identifying an array to which to append the value.value
- the value to prepend
-
arrayInsert
public static <T> ArrayInsert arrayInsert(String path, Object value)
Creates a command with the intention of inserting a value into an existing JSON array.Will error if the last element of the path does not exist or is not an array.
- Parameters:
path
- the path identifying an array to which to append the value, and an index. E.g. "foo.bar[3]"value
- the value to insert
-
arrayAddUnique
public static <T> ArrayAddUnique arrayAddUnique(String path, Object value)
Creates a command with the intent of inserting a value into an existing JSON array, but only if the value is not already contained in the array (by way of string comparison).Will error if the last element of the path does not exist or is not an array.
- Parameters:
path
- the path identifying an array to which to append the value, and an index. E.g. "foo.bar[3]"value
- the value to insert
-
increment
public static <T> Increment increment(String path, long delta)
Creates a command with the intent of incrementing a numerical field in a JSON object. If the field does not exist then it is created and takes the value of `delta`.- Parameters:
path
- the path identifying a numerical field to adjust or create.delta
- the value to increment the field by.
-
decrement
public static <T> Increment decrement(String path, long delta)
Creates a command with the intent of decrementing a numerical field in a JSON object. If the field does not exist then it is created and takes the value of `delta` * -1.- Parameters:
path
- the path identifying a numerical field to adjust or create.delta
- the value to increment the field by.
-
-