/
Data Protection in an Aggregation
Data Protection in an Aggregation
In order to turn of the display of data in an chart or aggregation if the number of answers falls below a certain threshhold (in this case 5), add these stages above the regular aggregation.
$facet
{
"count": [
{
"$count": "result"
}
],
"values": [
{
"$match": {}
}
]
}
$group
{
"count": {
"$first": "$count.result"
},
"values": "$values"
}
$redact
{
"$cond": {
"if": {
"$lt": [
"$count",
5
]
},
"then": "$$PRUNE",
"else": "$$KEEP"
}
}
$unwind
$replaceRoot