I have to perform update, match, unwind operation to secondary member but on secondary I will not be able to create out- collection, so what i want is I will perform aggregation on secondary and output should restore to my remote host for further processing of data.
Asked
Active
Viewed 341 times
0
-
If it's an "update" then you need to write to the "Primary". There simply is no other way around that. There is also no such thing as "update" using aggregation. `$out` creates a **completely new collection**. This is **NOT** and update. Updates require looping, or can be directly applied with `"multi"`. So no idea what you are saying here. Perhaps you should clarify by example, rather than a few sentences. – Neil Lunn Jun 22 '17 at 07:02
-
Thank you for revert Neil, Is it possible to make $out collection create to different host(lets say my test machine) and run aggregation to secondary node – Aayushi Jun 22 '17 at 08:59
-
`$out` only ever goes to the ["current database"](https://docs.mongodb.com/manual/reference/operator/aggregation/out/#create-new-collection) which means in the same space as the collection you are running the aggregate statement on. I think you are reading [this post](https://stackoverflow.com/a/37280419/2313887) where I have commented to the author that the information is **misleading**. Aggregate is not intended for "update" purposes, and you should therefore be following one of the `.bulkWrite()` examples instead. – Neil Lunn Jun 22 '17 at 09:12