Update

../../../../_images/update_mongodb.svg

Update one or more documents in the database

Documentation

Update documents from the database matching filter.

When upsert is active and no document matches filter a new document of Update will be created.

The modifications are specified using Update which can be either an update operator expression or an aggregation pipeline. Refer to https://www.mongodb.com/docs/v7.0/reference/operator/update/ for writing operator expressions, and https://www.mongodb.com/docs/v7.0/reference/operator/aggregation-pipeline/ for aggregation pipelines.

The node can be configured to perform an Update One or an Update Many operation. This determines if the update should be performed on only the first or all documents matching filter.

Filter and Update can be specified either as part of the configuration or using opt-in json-ports.

See https://docs.mongodb.com/manual/reference/method/db.collection.updateOne/ and https://docs.mongodb.com/manual/reference/method/db.collection.updateMany/ for more details.

For info on how to input data to MongoDB, see MongoDB data format.

This node can output a write operation, see Output write operation.

Definition

Input ports

mongodb mongodb

MongoDB

filter 0 - 1, json

Filter

update 0 - 1, json

Update

Output ports

mongodb 0 - 1, mongodb

MongoDB

update_result 0 - 1, json

Update result

write_operation 0 - 1, json

Write operation. Output write operation instead of performing the operation directly. The write operation can be used as an element in a bulk write input list

Configuration

Filter (filter)

Filter as json.

Operation (operation)

Operation used for updating.

Update (update)

Update as json

Upsert (upsert)

If True, perform an insert if no documents match the filter.

Examples

Implementation

class node_mongodb.MongoDBUpdate[source]