I created a native query in Metabase to return all restaurants created from a specific day onward:
[
{
$match: {
"restaurant_id": {
"$eq": ObjectId({{restaurant_id}})
},
"$expr": {
"$gt": [
{ "$toDate": "$_id" },
{ "$toDate": {{start_date}} }
]
}
}
}
]
This query runs successfully when executed as a standalone query in Metabase. However, when I add this question to a dashboard and link it to a date filter, I get no results.
I am using MongoDB. If I explicitly store a "created_date" field in my database and filter by it, the filtering works as expected. However, this approach is redundant because MongoDB already stores the creation timestamp in the ObjectId.
It seems like the issue is related to how Metabase handles date filters when linking dashboard parameters to native queries. Any insights or workarounds would be appreciated!