Skip to content

Commit

Permalink
fix: Update MongoDBVersionedUpdateOne docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamTolmay authored Nov 20, 2024
1 parent 3c87146 commit cf6d0e0
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions apps/docs/community-plugin-mongodb/MongoDB.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ _ref:
- `'$clusterTime': object` - An object containing data on the cluster time and signature.
- `operationTime: date` - Timestamp object of the operation time.
> To ensure that the most recent document is updated, a `sort` specification should be given in the find options.
#### Example
###### Find the document with the highest item number and insert an identical document with a new name. A new document is inserted if none is found.
Expand All @@ -243,32 +245,34 @@ _ref:
type: MongoDBVersionedUpdateOne
connectionId: items
properties:
filter:
entity_id: 123
update:
$set:
name: New Name
updated_at:
_date: now
options:
find:
sort:
item_number: -1
updated_at: -1
update:
upsert: true
filter:
name: 'old_item'
update:
$set:
name: 'new_item'
```
###### Before
```json
[
{"_id": ObjectId("..."), "name": "old_item", item_number: 2, "item_id": "old_item_2"},
{"_id": ObjectId("..."), "name": "old_item", item_number: 1, "item_id": "old_item_1"},
{"_id": ObjectId("..."), "entity_id": 123, "name": "Name", "value": 23,"updated_at": ISODate("2024-01-01") },
{"_id": ObjectId("..."), "entity_id": 123, "name": "Name", "value": 33, "updated_at": ISODate("2024-03-01")},
]
```
###### After
```json
[
{"_id": ObjectId("..."), "name": "old_item", item_number: 2, "item_id": "old_item_2"},
{"_id": ObjectId("..."), "name": "old_item", item_number: 1, "item_id": "old_item_1"},
{"_id": ObjectId("..."), "name": "new_item", item_number: 2, "item_id": "old_item_2"},
[
{"_id": ObjectId("..."), "entity_id": 123, "name": "Name", "value": 23,"updated_at": ISODate("2024-01-01") },
{"_id": ObjectId("..."), "entity_id": 123, "name": "Name", "value": 33, "updated_at": ISODate("2024-03-01")},
{"_id": ObjectId("..."), "entity_id": 123, "name": "New Name", "value": 33, "updated_at": ISODate("2024-11-01")},
]
```

0 comments on commit cf6d0e0

Please sign in to comment.