Get Mongo block allows you to write a query to read from the MongoDB. It helps you interact with MongoDB directly from the Neo UI, allowing you to fetch data from a MongoDB collection based on a specific query.
Example Scenario
Requirement
An airline brand allows customers to redeem loyalty points to book flight tickets for their dependants. However, before redeeming points, the dependants must be added as nominees. The system stores nominee details in a separate MongoDB table, with a maximum limit of five nominees per customer. Before adding a new nominee, the system must verify that the total number of nominees is less than five.
Solution
To implement this, create a dataflow that retrieves a customer's nominee information. Use a GetMongo block to determine the number of existing nominees.
Refer to this example dataflow to understand how it is configured for a use case. Make sure that you have access to DocDemo org (100737) and access to Neo.
Configuring the Get Mongo Block
To configure the Get Mongo block,
- From the dataflow canvas, click on the node and select the GET Mongo block.
- In the Block name field, enter the block name.
Note: Block names cannot contain spaces or special characters, except for underscores (_). Use camelCase or snake_case formatting. - In the Collection Name field, enter the name of the MongoDB collection you want to query.
- In the Query field, use JavaScript to enter the criteria for fetching data from MongoDB.
- In the Sort field, specify how to sort the results. You can sort the results in ascending (represented by 1) or descending order (represented by -1). To sort, include the field and the sort order in the syntax {field: sorting_order}. If sorting is not required, use
{}
as the default value.
Example usage:
{age:1} - Sorts the age field in ascending order
{age:-1} - Sorts the age field in descending order - (Optional) In the Limit field, specify the limit on the number of data fetched. In the Options field, specify any additional options for the query. These options modify query behavior and how results are returned.
Note: For information on available options, refer to the MongoDB documentation on options. - Configure the Input execution logic, Cachable feature and define the execution path as per the requirement.
- Click Done.

Configuring GET Mongo block