Can any one help me with below case in MongoDB:
- find documents with a condition from Collection A. (lets say we got 2 documents)
- Modify those 2 documents and then insert into Same collection A , with out disturbing original 2 documents.
Aggregation wont support merge into same collection, I got it through simple javascript, but we need in MapReduce.
Below is my Simple Script:
db.col1.find({
"field1": "value"
}).forEach(function(d1) {
d1.f2 = NumberInt(d1.f2 / 10);
db.col1.save(d1)
})