Is it possible to $merge and return?

What if we want to merge the aggregated docs and also return them? Did I understand it right that the only way to achieve this to $merge and then to extra query AGAIN for these document?

If yes, isn’t that stupid? Wouldn’t it be great $merge would have an option to also the return these documents?

1 Like

Hi @max_matinpalo, you will need that extra query in any case.

That’s not possible right now. If you just want the results, just execute all the stages in the aggregation pipeline before the $merge stage. But if you want it to be outputted into another collection you’ll need that extra query.

In case you have any doubts, please feel free to reach out to us.

Thanks and Regards.
Sourabh Bagrecha

1 Like