Consider we have two collection coll1 and coll2. I am applying some aggregation stages to the coll1
db.coll1.aggregate([
{ $match: { ... } },
{ $lookup:{
from: "coll2",
localField: "_id",
foreignField: "_id",
as: "coll2"
}
}
// followed by other stages
//last stage being $merge
{ $merge : { into: "coll3", on: "_id"} }
])
So, my query is:
- While the aggregation is in progress, is it possible the underlying collection, in this case
coll1, is allowed to be modified/updated ? In either case, please help to understand how it works (went through mongoDb docs, but could not understand) - How does it write the final
coll3? In sense, does it write all in one shot or one document as it finish the pipeline ? - In regards to
spring-data-mongodb, I am successfully able to callmongoOperation.aggregate()for the above aggregation pipeline, but it returnsaggregationResultobject with ZeromappedResults.( When checked in db, coll3 is getting created). Does$mergenot return any such details ?
I am using mongoDb 4.2