Using Custom Filter Queries In MongoDB Actions ​

Using the Custom filter query field, you can filter the documents used in MongoDB actions in your recipes.


Supported Actions ​

Custom filter queries are supported for the following MongoDB actions:


How it works ​

Using MongoDB's Extended JSON, you can construct queries that return a subset of documents from a collection.

Custom filter queries support:

Using BSON Types ​

Custom filter queries accept BSON types, with some limitations.

For example: This query would return documents with an ObjectId (oid) value of 5d505646cf6d4fe581014ab2:

json
{
   "_id":{
      "$oid":"5d505646cf6d4fe581014ab2"
   }
}

Using JSON Types ​

Custom filter queries also accept JSON data types such as string, boolean, number, etc.

For example: The following query returns documents where the document's manager_id value is a string type:

json
{
   "manager_id":"string"
}

Using Query Operators ​

You can also use query operators to perform comparison and logic operations. Note: There are some limitations on the operators that are currently supported.

For example: We'll use this query to search for documents in an employees collection:

json
{
   "manager_id":{
      "$oid":"5d505646cf6d4fe581014ab2"
   },
   "sales_closed":{
      "$gt":{
         "$numberDecimal":"1000000"
      }
   },
   "date_hired":{
      "$gt":{
         "$date":"2020-12-31T00:00:00.000Z"
      }
   }
}

The above query searches for documents - or employees - that:

  • Have a manager_id value of 5d505646cf6d4fe581014ab2)
  • Have a total sales_closed value greater than $1,000,000, and
  • Were hired after 2020-12-31 (December 31, 2020)

Limitations ​

  • Only the following BSON types are currently supported:
    • Decimal128, synonymous with $numberDecimal
    • ObjectId, synonymous with $oid
    • Date, synonymous with $date
  • The $where query operator isn't currently supported

Resources ​

Last updated: