public class Updater extends QueryBuilder<Updater>
filterObject, FILTERS, mixing, mongo
Modifier | Constructor and Description |
---|---|
protected |
Updater(Mongo mongo) |
Modifier and Type | Method and Description |
---|---|
Updater |
addToSet(Mapping field,
Object value)
Adds the given value to the given set / list.
|
Updater |
addToSet(String field,
Object value)
Adds the given value to the given set / list.
|
com.mongodb.client.result.UpdateResult |
executeFor(Class<?> type)
Executes the update on the given collection.
|
com.mongodb.client.result.UpdateResult |
executeFor(MongoEntity entity)
Executes the update on the given entity.
|
com.mongodb.client.result.UpdateResult |
executeFor(String collection)
Executes the update on the given collection.
|
Updater |
inc(Mapping field,
int value)
Increments the given field by the given value.
|
Updater |
inc(String field,
int value)
Increments the given field by the given value.
|
Updater |
many()
Specifies that multiple documents should be updated.
|
protected org.bson.Document |
prepareUpdate(String collection) |
Updater |
pull(Mapping field,
Object value)
Removes all occurences of the given value from the list in the given field.
|
Updater |
pull(String field,
Object value)
Removes all occurences of the given value from the list in the given field.
|
Updater |
pullAll(Mapping field,
Object... values)
Removes all occurences of the given values from the list in the given field.
|
Updater |
pullAll(String field,
Object... values)
Removes all occurences of the given values from the list in the given field.
|
Updater |
set(Mapping field,
Object value)
Sets a field to a new value.
|
Updater |
set(String field,
Object value)
Sets a field to a new value.
|
Updater |
setList(Mapping key,
Object... values)
Sets a field to the given list of values.
|
Updater |
setList(String key,
Object... values)
Sets a field to the given list of values.
|
Updater |
unset(Mapping field)
Unsets a field.
|
Updater |
unset(String field)
Unsets a field.
|
Updater |
upsert()
Specifies that a new document should be created if the update filter does not match anything.
|
getRelationName, toString, traceIfRequired, transferFilters, where, where, where
protected Updater(Mongo mongo)
public Updater many()
By default only one document is updated.
public Updater upsert()
By default nothing happens if the update filter does not match anything.
public Updater set(Mapping field, Object value)
field
- the field to updatevalue
- the new value of the fieldpublic Updater set(String field, Object value)
field
- the field to updatevalue
- the new value of the fieldpublic Updater unset(Mapping field)
field
- the field to removepublic Updater unset(String field)
field
- the field to removepublic Updater setList(Mapping key, Object... values)
key
- the name of the field to setvalues
- the values to set the field topublic Updater setList(String key, Object... values)
key
- the name of the field to setvalues
- the values to set the field topublic Updater inc(Mapping field, int value)
field
- the field to incrementvalue
- the amount by which the field should be incrementedpublic Updater inc(String field, int value)
field
- the field to incrementvalue
- the amount by which the field should be incrementedpublic Updater addToSet(Mapping field, Object value)
field
- the field containing the set / listvalue
- the value to addpublic Updater addToSet(String field, Object value)
field
- the field containing the set / listvalue
- the value to addpublic Updater pullAll(Mapping field, Object... values)
field
- the field containing the listvalues
- the values to removepublic Updater pullAll(String field, Object... values)
field
- the field containing the listvalues
- the values to removepublic Updater pull(Mapping field, Object value)
field
- the field containing the listvalue
- the value to removepublic Updater pull(String field, Object value)
field
- the field containing the listvalue
- the value to removepublic com.mongodb.client.result.UpdateResult executeFor(Class<?> type)
type
- the type of entities to updatepublic com.mongodb.client.result.UpdateResult executeFor(MongoEntity entity)
entity
- the entity to filter (by ID) and updatepublic com.mongodb.client.result.UpdateResult executeFor(String collection)
collection
- the collection to updateCopyright © 2018. All rights reserved.