Partial update removes all other fields in mongodb In DB:
{
"demo": [
{
"id": "ABC123",
"order": [
{
"order": 2,
"field": "fieldValue"
}
],
"items": [
"Story"
],
"statusList": [
"In progress"
]
}
]
}
In java Code:
collection.updateOne(Filters.eq("id", "ABC123"), new Document("$set", doc));
// doc is the document created from Model class
I doc i am passing values for only order. After running Java code it is updating items and statusList as null because of my Model class What should i do? Thanks in advance