Skip to content

Filter Objects Mutation ​

The Filter objects mutation keeps or removes whole objects in a list of objects based on one of their attributes. It works like Filter, but checks an attribute of each object instead of the entry itself.

Options ​

  • Operation: Choose between keep to include objects or remove to exclude objects.
  • Attribute: The attribute the condition is checked against on each object. Use dot paths for nested attributes, for example address.city, and [0] to pick an entry of a nested list, for example images[0].url. The attribute name is a value, so it can also come from a product field or the current item. Leave it empty to match the whole object as JSON text.
  • Condition: The type of match to use: equals, includes, starts with, ends with, empty, not empty, greater than or less than. Text conditions are case-insensitive unless case sensitivity is enabled. Greater than and less than compare numbers, and an attribute that is not a number never matches.
  • Value to filter by: The value or product attribute to match against. Not used with empty and not empty.

An object without the attribute reads as empty, so it is removed by keep conditions such as includes and kept by empty. Filter objects needs a list of objects; a single JSON object is not a list.

Example ​

The extra field videos holds this list of videos, parsed with Parse JSON:

json
[
  { "name": "hero.mp4", "url": "https://cdn.example.com/hero.mp4" },
  { "title": "lifestyle.mp4", "url": "https://cdn.example.com/lifestyle.mp4" },
  { "name": "hero-2.mp4", "url": "https://cdn.example.com/hero-2.mp4" }
]

Filter objects with operation keep, attribute name, condition includes and value hero keeps the first and the third object. The second object has no name, so it reads as empty and is removed. Following it with Pluck attribute and attribute url gives the two hero URLs.