Skip to main content

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
NAMETYPEDESCRIPTION
updatesorg.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
NAMETYPEDESCRIPTION
updatesjava.util.ListThe 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
NAMETYPEDESCRIPTION
namestringThe array field name.
ojava.lang.ObjectThe 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
NAMETYPEDESCRIPTION
namestringThe current field name.
newNamestringThe 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
NAMETYPEDESCRIPTION
namestringThe field name.
ojava.lang.ObjectThe 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
NAMETYPEDESCRIPTION
namestringThe field name.
Return

( org.bson.conversions.Bson )

The update in Bson format.