Overview
This node performs advanced MongoDB operations with type control, specifically supporting insert, update, and find operations on MongoDB collections. For the 'Find' operation, it allows users to query documents in a specified collection using customizable filters, sorting, limits, and skip options. This is useful for retrieving specific data sets from MongoDB based on dynamic criteria, such as filtering users by age or status, sorting results by creation date, and paginating results.
Use Case Examples
- Find all documents in a 'users' collection where 'status' is 'active', sorted by 'createdAt' descending, limited to 10 results.
- Retrieve documents from an 'orders' collection with a filter on 'orderDate' after a certain date, skipping the first 5 results for pagination.
Properties
| Name | Meaning |
|---|---|
| Coleção | The name of the MongoDB collection to query. |
| Filtro de Busca | Filters to apply for finding documents, each filter specifies a field name, its data type, and the value to filter by (which can be a literal or a path to input data). |
| Limite de Resultados | Maximum number of documents to return (0 means no limit). |
| Skip | Number of documents to skip before returning results (useful for pagination). |
| Ordenação (Sort) | Fields to sort the results by, each with a field name and order (ascending or descending). |
Output
JSON
jsonsuccess- Indicates if the find operation was successful (true).
Dependencies
- Requires a MongoDB connection credential with connection details such as connection string, database name, and authentication.
Troubleshooting
- Common issues include invalid filter values that do not match the expected data type, such as an invalid ObjectId format or an invalid date string. The node throws descriptive errors indicating the expected format.
- Connection errors may occur if the MongoDB credentials are incorrect or the database is unreachable; ensure the connection string and credentials are correct.
- If no documents are returned, verify that the filter criteria match existing documents in the collection.
- Errors during execution include messages like 'Valor inválido para ObjectId' indicating an invalid ObjectId format, or 'Valor inválido para Date' indicating an invalid date format. Correct the input values accordingly.
Links
- MongoDB Query Documents - Official MongoDB documentation on querying documents, useful for understanding filter syntax and options.
- MongoDB find() Method - Detailed reference for the find() method used to query documents in MongoDB collections.
