# 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 (opens new window), 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 (opens new window), with some limitations.

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

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

# Using JSON Types

Custom filter queries also accept JSON data types (opens new window) such as string, boolean, number, etc.

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

{
   "manager_id":"string"
}

# Using Query Operators

You can also use query operators (opens new window) 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:

{
   "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


# Resources


Last updated: 1/11/2022, 5:21:18 PM