I have some entities like that:
{
"id": 1,
...
"items": [
{
"name": "name_1",
...
}
]
}
I need to upsert that document in MongoDB, that means:
- if there is no documents with id == 1, then save a new document
- if there is document with id == 1, then I need to add 'item' from given document to persisted.
It is neccessary to do this by atomic operation. I use SpringData and MongoTemplate and tried to use aggregate operations, but didn't manage to achieve expected behavior.
Maybe somenopne knows how to do it with Spring Data?