collection.group
Run a group command across a collection.
Arguments
keys
(object | array | function) - An object, array or function expressing the keys to group by.condition
(Object) - An optional condition that must be true for a row to be considered.initial
(Object) - Initial value of the aggregation counter object.reduce
(Function) - The reduce function aggregates (reduces) the objects iterated.[
finalize
] (Function) - An optional function to be run on each item in the result set just before the item is returned.[
command
] (Boolean) - Specify if you wish to run using the internal group command or using eval, default is true.[
options
] (Object)[
callback
] (function)
Returns
A promise.
Example
users.group(
{ a: true },
{},
{ count: 0 },
function (obj, prev) {
prev.count++
},
true
)