MongoDB Update or Replace
Updates or replaces documents in MongoDB
Processing
Performs an updateOne or replaceOne operation using the given configuration.
Settings
Name | Type | Description |
---|---|---|
Query | ||
Connection |
dict |
The MongoDB connection to use. Evaluated for each input row |
Database |
string |
The database to use. Evaluated for each input row |
Collection |
string |
The collection to write to. Evaluated for each input row |
Operation |
string |
The operation to perform:
Evaluated for each input row |
Filter |
string or dict |
Specifies a filter that finds the document to update or replace as a BSON document. If you wish to update a document by id, supply a filter of the form:
In case the id value is of type ObjectId, it takes the form of a dict: Evaluated for each input row |
Update |
string, dict, or list |
Specifies how to update the document. The value is interpreted depending on the chosen operation. If operation is Example for update document:
Example for update with aggregation pipeline:
If operation is Evaluated for each input row |
Array Filters |
list |
Optional specification of array elements update. Only used when operation is set to Evaluated for each input row |
Processing | ||
Upsert |
boolean |
If Evaluated for each input row |
Bypass Validation |
boolean |
If Evaluated for each input row |
The Filter, Update, and Array Filters settings are parsed as a BSON document when given as string.
Values and BSON are converted as per the following table:
Value Type | Bson Type |
---|---|
boolean | bool |
long | int or long |
double | double |
decimal | decimal |
datetime | date |
string | string |
binary | binary |
list | array |
dict | object |
Dicts of the form {'$oid' string}
are converted to BSON ObjectIds and vice versa.
Function values cannot be converted to BSON.
Note:
Converting a dict to BSON generally results in an unspecified key order in the BSON object.
If the order of keys is important, you can supply a specially constructed dict of the form:
{
:__bson [
[key1, value1],
[key2, value2],
...
]
}
Such dicts are converted to a BSON object with the order of key-value pairs preserved:
{
key1: value1,
key2: value2,
...
}
You can use the BSON widget to generate such dicts in the UI.
Results
Name | Type | Description |
---|---|---|
inserted_id |
any | The id of any inserted document in case the upsert option resulted in a new document being created. |
matched_count |
long | The number of documents that matched the filter condition. |
modified_count |
long | The number of modified documents. |