I'm not a Mongo expert. I'm trying to update the complete document by replacing with the new one.
I have the following fields in the existing document in the collection
qid, column a, column b, column c
The new document has the following fields
qid, column a, column b, column d, column e (column c is not available)
So, when I try to update the document with the below code, it gets updated as following in the document in the collection
qid, column a, column b, column c, column d, column e
List<WriteModel> updateList = new ArrayList<WriteModel>(documents.size());
documents.stream().forEach((document) -> {
updateList.add(new UpdateOneModel<Document>(
new Document().append("qid", qid),
new Document().append("$set", document)));
});
BulkWriteResult result = securitiesCollection.bulkWrite(updateList,
MongoDbConstants.ORDERED_OPTION_FALSE);
How can I update the complete new document set in the collection by removing the existing document?