I am trying to do a pivot table in my kotlin application, and I have the stages working in compass, going to my collection, but when I convert this to kotlin I get the following error.
{
"_id": {
"status": "$_id.status"
},
"data": {
"$push": {
"$cond": [
{
"$ne": [
"$_id.status",
null
]
},
{
"k": "$_id.status",
"v": "$count"
},
{
"k": "Blank",
"v": "$count"
}
]
}
}
}
This is the kotlin code:
val stage4 = "{ '_id': { 'status': '\$_id.status' }, 'data': { '\$push': { '\$cond': [ { '\$ne': [ '\$_id.status',null ] }, { 'k': '\$_id.status', 'v': '\$count' }, {'k': 'Blank', 'v': '\$count' } ] } } } "
And I add this result to the list: group(Document.parse(stage4))
And I get this error.
The full response is {“ok”: 0.0, “errmsg”: “Unrecognized expression ‘$push’”, “code”: 168, “codeName”: “InvalidPipelineOperator”}"