1001fx - NoCode functions icon

1001fx - NoCode functions

1001fx is a set of functions for any automation platform. Our functions are simple, very well tested, scalable and offer features that most automation platforms do not offer.

Actions74

array → Filter an Array by an Operator

AI-generated

Overview

This node provides a "Filter an Array by an Operator" operation for the "array" resource. It allows you to filter an array of objects based on a specified field, operator, and criteria. This is useful in scenarios where you need to extract only those items from a dataset that match certain conditions, such as filtering orders above a certain value, selecting users with a specific status, or extracting records within a date range.

Practical examples:

  • Filtering a list of products to include only those with a price greater than $100.
  • Selecting users whose email addresses match a specific domain (with optional case sensitivity).
  • Extracting log entries where the severity equals "error".

Properties

Name Meaning
Data Array of lines with mixed values. The input array to be filtered.
Query field Name of the field in each array item to apply the filter condition. Case sensitive.
Operator Comparison operator to use for filtering. Options: eq (equals), ge (greater or equal), gt (greater than), le (less or equal), lt (less than), ne (not equal). Defaults to eq.
Criteria Value to compare against. Must be a number or string.
Ignore case sensitivity If enabled, the comparison will ignore case differences (for string fields).

Output

The output is a JSON array containing only those items from the input "Data" array that match the specified filter condition. Each output item retains its original structure.

Example output:

[
  {
    "field1": "value1",
    "field2": 123
  },
  {
    "field1": "value2",
    "field2": 456
  }
]
  • If no items match, the output will be an empty array.
  • No binary data is produced by this operation.

Dependencies

  • External Service: Requires access to the 1001fx API.
  • API Key: You must configure the 1001fxApi credential in n8n.
  • Environment: Ensure your n8n instance can reach https://api.1001fx.com/.

Troubleshooting

  • Common Issues:

    • Invalid API Key: If the API key is missing or incorrect, authentication errors will occur. Make sure the 1001fxApi credential is set up correctly.
    • Incorrect Field Name: If the "Query field" does not exist in the data, no items will match, resulting in an empty output.
    • Type Mismatch: If "Criteria" is a string but the field is numeric (or vice versa), the filter may not work as expected.
    • Case Sensitivity: If "Ignore case sensitivity" is not enabled, string comparisons are case-sensitive, which may lead to unexpected results.
  • Error Messages:

    • Errors from the API are returned in the output under an error property. For example:
      { "error": "Invalid operator" }
      
      To resolve, check that all properties are set correctly and the operator is valid.

Links and References

Discussion