How do I perform an union of two distinct collection in aggregation framework

Hello @Ezequias_Rocha

the $unionWith aggregation stage which @Justin mentioned looks very promising and will simplify the code a lot. There is a release candidate 4…4.0.rc0 available you may want to try that out (I will next week).

I once had this issue too, but could fix it by adopting the needs to my data model, that is not always possible. Checking stackoverflow I found this anwers (which comes close to the one @Natac13 already posted.)

Hope that helps
Michael

1 Like