public class Update extends Object
| Modifier and Type | Class and Description |
|---|---|
class |
Update.AddToSetBuilder
Builder for creating
$addToSet modifier. |
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) |
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 |
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 |
fromDBObject(com.mongodb.DBObject object,
String... exclude)
Creates an
Update instance from the given DBObject. |
com.mongodb.DBObject |
getUpdateObject() |
int |
hashCode() |
Update |
inc(String key,
Number inc)
Update using the $inc update modifier
|
boolean |
modifies(String key)
Determine if a given
key will be touched on execution. |
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 fromDBObject(com.mongodb.DBObject object, String... exclude)
Update instance from the given DBObject. Allows to explicitly exlude 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 DBObject will be nulled when executing the update. To
create an only-updating Update instance of a DBObject, call set(String, Object) for each
value in it.object - the source DBObject to create the update from.exclude - the fields to exclude.public Update set(String key, Object value)
key - value - http://docs.mongodb.org/manual/reference/operator/update/set/public Update setOnInsert(String key, Object value)
key - value - http://docs.mongodb.org/manual/reference/operator/update/setOnInsert/public Update unset(String key)
key - http://docs.mongodb.org/manual/reference/operator/update/unset/public Update inc(String key, Number inc)
key - inc - http://docs.mongodb.org/manual/reference/operator/update/inc/public Update push(String key, Object value)
key - value - http://docs.mongodb.org/manual/reference/operator/update/push/public Update.PushOperatorBuilder push(String key)
$push modifier. $push command for single or multiple (using $each) values.key - Update.PushOperatorBuilder for given keyhttp://docs.mongodb.org/manual/reference/operator/update/push/,
http://docs.mongodb.org/manual/reference/operator/update/each/public 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 - http://docs.mongodb.org/manual/reference/operator/update/pushAll/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 - http://docs.mongodb.org/manual/reference/operator/update/addToSet/public Update pop(String key, Update.Position pos)
key - pos - http://docs.mongodb.org/manual/reference/operator/update/pop/public Update pull(String key, Object value)
key - value - http://docs.mongodb.org/manual/reference/operator/update/pull/public Update pullAll(String key, Object[] values)
key - values - http://docs.mongodb.org/manual/reference/operator/update/pullAll/public Update rename(String oldName, String newName)
oldName - newName - http://docs.mongodb.org/manual/reference/operator/update/rename/public Update currentDate(String key)
key - http://docs.mongodb.org/manual/reference/operator/update/currentDate/public Update currentTimestamp(String key)
key - http://docs.mongodb.org/manual/reference/operator/update/currentDate/public com.mongodb.DBObject getUpdateObject()
protected void addMultiFieldOperation(String operator, String key, Object value)
public boolean modifies(String key)
key will be touched on execution.key - Copyright © 2011-2014–2014 Pivotal Software, Inc.. All rights reserved.