I am trying to group and sub-group
const [
{ type: "agency", properties: 10 },
{ type: "host", properties: 50 },
{ type: "agency", properties: 40 },
{ type: "landlord", properties: 50 },
{ type: "host", properties: 80 }
...
];
pipeline.push({
$group: {
_id: "$type",
"All": { $count: { } },
"Below 30": {
$sum: {
"properties": {
$gte: 0,
$lt: 30
}
}
}
}
});
This code is obviously not correct. Does anyone know how to do this ?
Daniel