public class Update extends Object implements UpdateDefinition
| Modifier and Type | Class and Description |
|---|---|
class |
Update.AddToSetBuilder
Builder for creating
$addToSet modifier. |
static class |
Update.BitwiseOperatorBuilder |
static interface |
Update.Modifier
Marker interface of nested commands.
|
static class |
Update.Modifiers
Modifiers holds a distinct collection of
Update.Modifier |
static class |
Update.Position |
class |
Update.PushOperatorBuilder
Builder for creating
$push modifiers |
UpdateDefinition.ArrayFilter| Constructor and Description |
|---|
Update() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addFieldOperation(String operator,
String key,
Object value)
Deprecated.
|
protected void |
addMultiFieldOperation(String operator,
String key,
Object value) |
Update.AddToSetBuilder |
addToSet(String key)
Update using
$addToSet modifier. |
Update |
addToSet(String key,
Object value)
Update using the $addToSet update modifier
|
Update.BitwiseOperatorBuilder |
bitwise(String key)
The operator supports bitwise
and, bitwise or, and bitwise xor operations. |
Update |
currentDate(String key)
Update given key to current date using $currentDate modifier.
|
Update |
currentTimestamp(String key)
Update given key to current date using $currentDate : { $type : "timestamp" } modifier.
|
boolean |
equals(Object obj) |
Update |
filterArray(CriteriaDefinition criteria)
Filter elements in an array that match the given criteria for update.
|
Update |
filterArray(String identifier,
Object expression)
Filter elements in an array that match the given criteria for update.
|
static Update |
fromDocument(org.bson.Document object,
String... exclude)
Creates an
Update instance from the given Document. |
List<UpdateDefinition.ArrayFilter> |
getArrayFilters()
Get the specification which elements to modify in an array field.
|
org.bson.Document |
getUpdateObject() |
int |
hashCode() |
void |
inc(String key)
Increment the value of a given key by
1. |
Update |
inc(String key,
Number inc)
Update using the $inc update modifier
|
Boolean |
isIsolated()
If true prevents a write operation that affects multiple documents from yielding to
other reads or writes once the first document is written.
|
Update |
isolated()
Prevents a write operation that affects multiple documents from yielding to other reads or writes
once the first document is written.
|
Update |
max(String key,
Object value)
Update given key to the
value if the value is greater than the current value of the field. |
Update |
min(String key,
Object value)
Update given key to the
value if the value is less than the current value of the field. |
boolean |
modifies(String key)
Determine if a given
key will be touched on execution. |
Update |
multiply(String key,
Number multiplier)
Multiply the value of given key by the given number.
|
Update |
pop(String key,
Update.Position pos)
Update using the $pop update modifier
|
Update |
pull(String key,
Object value)
Update using the $pull update modifier
|
Update |
pullAll(String key,
Object[] values)
Update using the $pullAll update modifier
|
Update.PushOperatorBuilder |
push(String key)
Update using
$push modifier. |
Update |
push(String key,
Object value)
Update using the $push update modifier
|
Update |
pushAll(String key,
Object[] values)
Deprecated.
as of MongoDB 2.4. Removed in MongoDB 3.6. Use
$push $each instead. |
Update |
rename(String oldName,
String newName)
Update using the $rename update modifier
|
Update |
set(String key,
Object value)
Update using the $set update modifier
|
Update |
setOnInsert(String key,
Object value)
Update using the $setOnInsert update modifier
|
String |
toString() |
Update |
unset(String key)
Update using the $unset update modifier
|
static Update |
update(String key,
Object value)
Static factory method to create an Update using the provided key
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waithasArrayFilterspublic static Update update(String key, @Nullable Object value)
key - public static Update fromDocument(org.bson.Document object, String... exclude)
Update instance from the given Document. Allows to explicitly exclude fields from making
it into the created Update object. Note, that this will set attributes directly and not use
$set. This means fields not given in the Document will be nulled when executing the update. To
create an only-updating Update instance of a Document, call set(String, Object) for each
value in it.object - the source Document to create the update from.exclude - the fields to exclude.public Update set(String key, @Nullable Object value)
key - value - can be null. In this case the property remains in the db with a null value. To
remove it use unset(String).public Update setOnInsert(String key, @Nullable Object value)
key - value - can be null.public Update unset(String key)
key - public Update inc(String key, Number inc)
key - inc - public void inc(String key)
UpdateDefinition1.inc in interface UpdateDefinitionkey - must not be null.public Update push(String key, @Nullable Object value)
key - value - public Update.PushOperatorBuilder push(String key)
$push modifier. $push command for single or multiple (using $each) values as well as using
$position.key - Update.PushOperatorBuilder for given key@Deprecated public Update pushAll(String key, Object[] values)
$push $each instead.$pushAll update modifier. $pushAll has been deprecated in favor of $push $each.
Important: As of MongoDB 3.6 $pushAll is not longer supported. Use $push $each instead.
push(String)) returns a builder that can be used to populate the $each object.key - values - public Update.AddToSetBuilder addToSet(String key)
$addToSet modifier. $push command for single or multiple (using $each) valueskey - public Update addToSet(String key, @Nullable Object value)
key - value - public Update pop(String key, Update.Position pos)
key - pos - public Update pull(String key, @Nullable Object value)
key - value - public Update pullAll(String key, Object[] values)
key - values - public Update rename(String oldName, String newName)
oldName - newName - public Update currentDate(String key)
key - public Update currentTimestamp(String key)
key - public Update multiply(String key, Number multiplier)
key - must not be null.multiplier - must not be null.public Update max(String key, Object value)
value if the value is greater than the current value of the field.key - must not be null.value - must not be null.public Update min(String key, Object value)
value if the value is less than the current value of the field.key - must not be null.value - must not be null.public Update.BitwiseOperatorBuilder bitwise(String key)
and, bitwise or, and bitwise xor operations.key - public Update isolated()
MongoOperations.updateMulti(Query, Update, Class).public Update filterArray(CriteriaDefinition criteria)
CriteriaDefinition is passed directly
to the driver without further type or field mapping.criteria - must not be null.public Update filterArray(String identifier, Object expression)
expression is used directly with the
driver without further further type or field mapping.identifier - the positional operator identifier filter criteria name.expression - the positional operator filter expression.public Boolean isIsolated()
UpdateDefinitionisIsolated in interface UpdateDefinitionpublic org.bson.Document getUpdateObject()
getUpdateObject in interface UpdateDefinitionDocument format. Never null.public List<UpdateDefinition.ArrayFilter> getArrayFilters()
UpdateDefinitionUpdateDefinition.ArrayFilter are passed directly to the
driver without further type or field mapping.getArrayFilters in interface UpdateDefinition@Deprecated protected void addFieldOperation(String operator, String key, Object value)
addMultiFieldOperation(String, String, Object).operator - key - value - protected void addMultiFieldOperation(String operator, String key, @Nullable Object value)
public boolean modifies(String key)
key will be touched on execution.modifies in interface UpdateDefinitionkey - Copyright © 2011–2020 Pivotal Software, Inc.. All rights reserved.