Replace

../../../../_images/replace_mongodb.svg

Replace one document in the database.

Documentation

Replace a single document from the database matching Filter. If there are multiple matches, only the first match will be replaced.

What to replace with is specified using Replacement, which should be a complete replacement document. When upsert is active and no document matches Filter, a new document of the Replacement will be created.

Filter and Replacement 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.replaceOne/ 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
Type: mongodb
Description: MongoDB
filter
Type: json
Description: Filter
Optional number of ports: 0–1 (default: 0)
replacement
Type: json
Description: Replacement
Optional number of ports: 0–1 (default: 0)

Output ports

mongodb
Type: mongodb
Description: MongoDB
Optional number of ports: 0–1 (default: 1)
replace_result
Type: json
Description: Replace result
Optional number of ports: 0–1 (default: 1)
write_operation
Type: json
Description: 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
Optional number of ports: 0–1 (default: 0)

Configuration

Filter (filter)

Filter as json.

Replacement (replacement)

Replacement as json.

Upsert (upsert)

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

Examples

Example flows demonstrating this node:

Implementation

class node_mongodb.MongoDBReplace[source]