Calculates aggregate values for the data in a collection.
-
pipeline
(Array): A sequence of data aggregation operations or stages. -
[
options
] (object) -
[
callback
] (function)
A promise
users.aggregate([
{ $project : {
author : 1,
tags : 1
}},
{ $unwind : "$tags" },
{ $group : {
_id : {tags : "$tags"},
authors : { $addToSet : "$author" }
}}
]).then((res) => {})