|
Hi all. We are pleased to announce that a new aggregation stage $unionWith will be available in the 4.4 release. Here's one example, with more to come in documentation soon.
db.example.aggregate([
|
// Can have other stages here.
|
{$unionWith: {
|
coll: "otherCollectionName",
|
pipeline: [ /* Pipeline which will operator over "otherCollectionName" */ ]
|
}},
|
// Can have other stages here, applied to data from both "example" and "otherCollectionName".
|
]);
|
There is also a shorthand syntax when you don't need a sub-pipeline:
db.example.aggregate([
|
// Can have other stages here.
|
{$unionWith: "otherCollectionName"},
|
// Can have other stages here, applied to data from both "example" and "otherCollectionName".
|
]);
|
|