I want to add a variable to the given MongoDB query in Metabase. I know that it is supported after https://github.com/metabase/metabase/issues/3653 I have given my query below which is not working with the variable.
My query is:
[
{
"$project": {
"lastCommGenTS": "$lastCommGenTS",
"lastUpdated": "$lastUpdated",
"extBatMvLow": "$extBatMvLow",
"regNo": "$truckRegNo",
"derivedStatus": "$derivedStatus"
}
},
{
"$match": {
"$expr": {
"$and": [
{
"$eq": [
"$regNo",{{regNo}}
]
}
]
}
}
},
{
"$project": {
"_id": "$_id",
"regNo": "$regNo",
"derivedStatus": "$derivedStatus",
"lastcommtimeIST": {
"$dateToString": {
"format": "%Y-%m-%d %H:%M:%S",
"date": {
"$toDate": "$lastCommGenTS"
},
"timezone": "+05:30"
}
},
"lastupdatedIST": {
"$dateToString": {
"format": "%Y-%m-%d %H:%M:%S",
"date": {
"$toDate": "$lastUpdated"
},
"timezone": "+05:30"
}
},
"lag_in_minutes": {
"$divide": [
{
"$subtract": [
"$lastUpdated",
"$lastCommGenTS"
]
},
60000
]
}
}
}
]
The error is:
Unexpected character ('{' (code 123)): was expecting double-quote to start field name at [Source: java.io.StringReader@6bab96b; line: 17, column: 26]