Replace¶
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: mongodbDescription: MongoDB- filter
Type: jsonDescription: FilterOptional number of ports: 0–1 (default: 0)- replacement
Type: jsonDescription: ReplacementOptional number of ports: 0–1 (default: 0)
Output ports¶
- mongodb
Type: mongodbDescription: MongoDBOptional number of ports: 0–1 (default: 1)- replace_result
Type: jsonDescription: Replace resultOptional number of ports: 0–1 (default: 1)- write_operation
Type: jsonDescription: 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 listOptional 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]