Find Many

Find Many node is designed to retrieve multiple records from a database based on a given query. It's useful when you need to fetch a set of documents that match specific criteria.

This node is particularly valuable when you want to retrieve multiple records that share certain characteristics or when you need to perform operations on a subset of your data.

Properties Panel

Field

Description

Required

Node name

true

Database collection

Database collection from which you want to retrieve multiple documents

true

Query

Query to identify which documents need to be retrieved

false

Projection

Specifies which fields to include or exclude in the result

false

Usage

  1. Select the database collection you want to search.

  2. Define your query to match the desired records. For example: { "status": { "$eq": "active" } }

  3. (Optional) Specify a projection to include only relevant fields. For example: { "name": 1, "email": 1, "_id": 0 }

Returns

result - An array of documents from the database that match the query. If no documents match the query, this will be an empty array.. You can access this using Magical Autocomplete (e.g. $.<node_name>.result) in any node below this node.

Example

Let's say you want to find all users who are over 18 years old, retrieve only their names and ages:

  1. Set Database Collection to users

  2. Set Query to { "age": { "$gt": 18 } }

  3. Set Projection to { "name": 1, "age": 1, "_id": 0 }

This will return a result like:

[
  {
    "name": "Alice Johnson",
    "age": 35
  },
  {
    "name": "Bob Smith",
    "age": 28
  },
  {
    "name": "Charlie Brown",
    "age": 22
  },
  ...
]

Best Practices

  • Use indexing on frequently queried fields to improve performance.

  • Be cautious with projections to avoid exposing sensitive data.

  • When possible, use specific queries to reduce the number of documents that need to be scanned.

Last updated