MongoUpdates
Definition of the changes in Bson that are used in data changes in MongoDB collections.
combine
combine(updates: org.bson.conversions.Bson[]) : org.bson.conversions.Bson
Description
Combine a list of updates into a single update.
How To Use
const setUpdate = _mongo.updates().set('quantity', 42);
const renameUpdate = _mongo.updates().rename('other', 'more');
const combinedUpdates = _mongo.updates().combine(setUpdate, renameUpdate);
collection.findOneAndUpdate(
_mongo.filters().eq('name', 'Abc'),
combinedUpdates
);
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| updates | org.bson.conversions.Bson[] | The list of updates. |
Return
( org.bson.conversions.Bson )
A combined update.
combine(updates: java.util.List<?>) : org.bson.conversions.Bson
Description
Combine a list of updates into a single update.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| updates | java.util.List | The list of updates. |
Return
( org.bson.conversions.Bson )
A combined update.
push
push(name: string, o: java.lang.Object) : org.bson.conversions.Bson
Description
Adds a value to an array in a document.
How To Use
_mongo.updates().push('tags', 'newTag');
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| name | string | The array field name. |
| o | java.lang.Object | The value to add. |
Return
( org.bson.conversions.Bson )
The update in Bson format.
rename
rename(name: string, newName: string) : org.bson.conversions.Bson
Description
Renames a field in a document.
How To Use
_mongo.updates().rename('oldName', 'newName');
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| name | string | The current field name. |
| newName | string | The new field name. |
Return
( org.bson.conversions.Bson )
The update in Bson format.
set
set(name: string, o: java.lang.Object) : org.bson.conversions.Bson
Description
Sets the value of a field in a document.
How To Use
_mongo.updates().set('name', 'new value');
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| name | string | The field name. |
| o | java.lang.Object | The value to set. |
Return
( org.bson.conversions.Bson )
The update in Bson format.
unset
unset(name: string) : org.bson.conversions.Bson
Description
Removes the value of a field in a document.
How To Use
_mongo.updates().unset('name');
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| name | string | The field name. |
Return
( org.bson.conversions.Bson )
The update in Bson format.