public class Update extends Object
| 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 |
| 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) |
static Update |
fromDocument(org.bson.Document object,
String... exclude)
Creates an
Update instance from the given Document. |
org.bson.Document |
getUpdateObject() |
int |
hashCode() |
Update |
inc(String key,
Number inc)
Update using the $inc update modifier
|
Boolean |
isIsolated() |
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)
Update using the
$pushAll update modifier. |
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
|
public static Update update(String key, 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, Object value)
key - value - public Update setOnInsert(String key, Object value)
key - value - public Update unset(String key)
key - public Update inc(String key, Number inc)
key - inc - public Update push(String key, 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 keypublic Update pushAll(String key, Object[] values)
$pushAll update modifier. $pushAll has been deprecated in favor of $push $each.
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, Object value)
key - value - public Update pop(String key, Update.Position pos)
key - pos - public Update pull(String key, 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 Boolean isIsolated()
public org.bson.Document getUpdateObject()
@Deprecated protected void addFieldOperation(String operator, String key, Object value)
addMultiFieldOperation(String, String, Object).operator - key - value - protected void addMultiFieldOperation(String operator, String key, Object value)
public boolean modifies(String key)
key will be touched on execution.key - Copyright © 2011–2018 Pivotal Software, Inc.. All rights reserved.