Query parameters for MongoDB

I am trying to add in query parameters for dashboard level on a MongoDB connection. Found a few support articles on how to write the JSON queries for date filtering, but nothing for writing query parameters for other field types, e.g. names or email addresses. Could you please assist with an example?

Technical details:

  • Redash Version:8
  • Browser/OS:Installed on Debian 8

A couple examples:

Date Filter

You’ll need the $humanTime extension, as discussed in our documentation:

The $humanTime function is also needed when using Query Parameters of type Date or Date/Time with MongoDB, due to the difference between the format Redash uses and the one MongoDB expects.

(When using a Date (or Date Range) parameter, wrap it with a $humanTime object: {{param}} becomes {"$humanTime": "{{param}} 00:00"} (the 00:00 suffix is needed only with Date parameters, for Date Time parameters you should skip it).

{
    "collection": "date_test",
    "query": {
        "lastModified": {
            "$gte": {
                "$humanTime": "{{ date_parameter }}"
            }
        }
    }
}

Email Address Filter

{
    "collection": "date_test",
    "query": {
        "status": {
            "$eq": "{{ email_address_parameter }}"
        }
    }
}