MongoDB
Overview
The MongoDB Tool allows Dataworkz Agents to query data stored in MongoDB collections using MongoDB’s native query language. This makes it possible to retrieve nested objects and execute advanced query constructs that are not supported by the Dataset tool. For simple fetches or tabular data, the Dataset tool is recommended.
When to Use
Use the MongoDB Tool when you need to:
Query data stored in a MongoDB database.
Work with nested documents or advanced MongoDB query structures.
Retrieve only specific fields using projections.
Prerequisites
A MongoDB connection must already be created in Data Studio under the Configurations section.
The connection should include authentication and access to the database you intend to query.
Set up
Creating a MongoDB Tool
To create a MongoDB Tool, navigate to Agents > Create Tool and select MongoDB from the tool types.

About Tool
Add details to help Agents understand what the tool is designed for.
Tool Name: Enter a descriptive name.
Description: Provide a short explanation of the tool’s purpose.
Configuration
Define how the tool connects to MongoDB and retrieves data.
Storage: Select the MongoDB connection configured in Data Studio.
Database: Choose the database to query.
Collection: Select the collection within the database.
Filter: Enter the BSON or JSON query template to execute. Parameters can be included here and will automatically appear as input parameters.
Example filter:

Input Parameters
Any variables defined in the filter (for example, ${orderId}) automatically appear here. Define the type and description for each parameter to make the tool easier to use.
Projections
MongoDB supports projections that specify which fields to include or exclude in the result set. Projections are powerful for limiting or shaping the data returned by queries.
Example projection:
Output
Describe the expected structure of the query results. This helps the Agent understand what kind of data will be returned.

Validation
After configuration, test the MongoDB Tool by providing values for the input parameters and running the query. Review the results to confirm the query and projections are working as intended.
Last updated

