Overview
This node performs a 'find' operation on a specified MongoDB collection. It allows users to query documents in the collection using a MongoDB query expressed in JSON format. Users can also specify options such as limit (maximum number of documents to return), skip (number of documents to skip), and sort order for the results. This operation is useful for retrieving filtered and sorted data from a MongoDB database, for example, fetching user records born after a certain date or retrieving the latest entries in a collection.
Use Case Examples
- Retrieve up to 50 documents from the 'users' collection where the 'birth' date is greater than '1950-01-01'.
- Fetch documents from a 'products' collection, skipping the first 10 and sorting by price in descending order.
Properties
| Name | Meaning |
|---|---|
| Collection | The MongoDB collection to query documents from. |
| Query (JSON Format) | The MongoDB find query expressed in JSON format to filter documents. |
| Options | Additional query options such as limit, skip, and sort order. |
Output
JSON
_id- The unique identifier of the MongoDB document.
- Other fields returned from the MongoDB document based on the query.
Dependencies
- MongoDB database connection with credentials
Troubleshooting
- Ensure the MongoDB connection credentials are correct and the database exists.
- Verify the collection name is correct and exists in the database.
- Check the JSON query syntax is valid and properly formatted.
- If using _id in the query, ensure it is a valid ObjectId string.
- Common errors include connection failures, invalid queries, or unsupported operations. Use the 'continueOnFail' option to handle errors gracefully.