generated from mintlify/starter
-
Couldn't load subscription status.
- Fork 13
Add MongoDB connection page #173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,281 @@ | ||
| --- | ||
| title: Using MongoDB with Hypermode | ||
| sidebarTitle: MongoDB | ||
| description: | ||
| Connect your Hypermode agent to MongoDB for scalable document database | ||
| operations | ||
| --- | ||
|
|
||
| <div className="flex items-center gap-3 mb-6"> | ||
| <img | ||
| src="/images/agents/connections/icons/mongodb.svg" | ||
| alt="MongoDB" | ||
| width={48} | ||
| height={48} | ||
| /> | ||
| <div> | ||
| <h2 className="text-2xl font-bold m-0">MongoDB</h2> | ||
| <p className="text-gray-600 m-0"> | ||
| Document-oriented NoSQL database platform | ||
| </p> | ||
| </div> | ||
| </div> | ||
|
|
||
| ## Overview | ||
|
|
||
| MongoDB is a popular NoSQL document database that provides flexible schema | ||
| design and powerful querying capabilities. This guide will walk you through | ||
| connecting your Hypermode agent to MongoDB, enabling seamless document | ||
| operations and data management for your applications. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| Before connecting MongoDB to Hypermode, you'll need: | ||
|
|
||
| 1. A [MongoDB Atlas account](https://www.mongodb.com/cloud/atlas) or local | ||
| MongoDB installation | ||
| 2. A MongoDB database with connection credentials | ||
| 3. A [Hypermode workspace](https://hypermode.com/) | ||
|
|
||
| ## Setting up MongoDB | ||
|
|
||
| ### Step 1: Create your MongoDB Atlas account | ||
|
|
||
| If you haven't already, sign up for a | ||
| [free MongoDB Atlas account](https://www.mongodb.com/cloud/atlas) to get started | ||
| with cloud-hosted MongoDB. | ||
|
|
||
| ### Step 2: Create a cluster and database | ||
|
|
||
| 1. Create a new cluster in MongoDB Atlas | ||
| 2. Set up database access credentials | ||
| 3. Configure network access (whitelist IP addresses) | ||
| 4. Create your first database and collection | ||
|
|
||
| Check the box to load sample data. This will create a movies database with | ||
| sample data in several collections. | ||
|
|
||
|  | ||
|
|
||
| You'll also need to create a user and password for your database. | ||
|
|
||
|  | ||
|
|
||
| ### Step 3: Generate connection string | ||
|
|
||
| Navigate to your cluster and get the connection string: | ||
|
|
||
| 1. Click "Connect" on your cluster | ||
| 2. Choose "Connect" | ||
| 3. Copy the connection string and replace `<password>` with your database user | ||
| password. You'll use this connection string to connect your Hypermode agent | ||
| to MongoDB. | ||
|
|
||
|  | ||
|
|
||
| <Note> | ||
| Your connection string will look like: | ||
| `mongodb+srv://username:[email protected]/database?retryWrites=true&w=majority` | ||
| </Note> | ||
|
|
||
| ### Step 4: Whitelist IP addresses | ||
|
|
||
| Navigate to your cluster and whitelist IP addresses to allow connections from | ||
| your Hypermode agent: | ||
|
|
||
| 1. Click "Network Access" on your cluster | ||
| 2. Add the IP address range `0.0.0.0/0` to allow connections from any IP address | ||
|
|
||
|  | ||
|
|
||
| ## Creating your MongoDB agent | ||
|
|
||
| ### Step 1: Create a new agent | ||
|
|
||
| From the Hypermode interface, create a new agent manually: | ||
|
|
||
| 1. Click the agent dropdown menu | ||
| 2. Select "Create new Agent" | ||
|
|
||
| ### Step 2: Configure agent settings | ||
|
|
||
| Use these recommended settings for your MongoDB agent: | ||
|
|
||
| - **Agent Name**: MongoAgent | ||
| - **Agent Title**: Connects to MongoDB | ||
| - **Description**: MongoAgent manages document operations | ||
| - **Instructions**: You have a connection to MongoDB and various other developer | ||
| tools to streamline document data access and management. You can perform CRUD | ||
| operations, aggregations, and complex queries on MongoDB collections. | ||
| - **Model**: GPT-4.1 | ||
|
|
||
|  | ||
|
|
||
| ## Connecting to MongoDB | ||
|
|
||
| ### Step 1: Add the MongoDB connection | ||
|
|
||
| Navigate to the **Connections** tab and add MongoDB: | ||
|
|
||
| 1. Click "Add connection" | ||
| 2. Select "MongoDB" from the dropdown | ||
|
|
||
|  | ||
|
|
||
| ### Step 2: Configure credentials | ||
|
|
||
| Enter your MongoDB credentials: | ||
|
|
||
| - **Username**: The username of your MongoDB user | ||
| - **Password**: The password of your MongoDB user | ||
| - **Database Name**: The default database to connect to | ||
| - **Hostname**: The hostname of your MongoDB cluster. This is the part of your | ||
| MongoDB connection string that comes after `mongodb+srv://` and is a domain | ||
| name. For example given the connection string | ||
| `mongodb+srv://will:<db_password>@hypermodeturorials.o7ygcmn.mongodb.net/?retryWrites=true&w=majority&appName=HypermodeTurorials`, | ||
| the hostname is `hypermodeturorials.o7ygcmn.mongodb.net` | ||
|
|
||
|  | ||
|
|
||
| <Warning> | ||
| Keep your connection string secure! This contains your database credentials | ||
| and should never be exposed in client-side code. | ||
| </Warning> | ||
|
|
||
| ## Testing the connection | ||
|
|
||
| Your agent can create collections, add documents, and perform queries on your | ||
| MongoDB database. Since we created a sample movies database, let's test it out | ||
| using the sample data in MongoDB. | ||
|
|
||
| ### Test 1: Query empty collections | ||
|
|
||
| Start a new thread and test with a simple query: | ||
|
|
||
| ```text | ||
| Can you show me all movies in the database? | ||
| ``` | ||
|
|
||
| You should see a MongoDB tool call in the chat history, confirming the | ||
| connection works: | ||
|
|
||
|  | ||
|
|
||
| ### Test 2: Insert documents | ||
|
|
||
| Now try adding data to your database: | ||
|
|
||
| ```text | ||
| Can you add The Matrix from 1999 directed by the Wachowskis to my MongoDB database? | ||
| ``` | ||
|
|
||
|  | ||
|
|
||
| ### Test 3: Complex queries | ||
|
|
||
| Test more advanced operations: | ||
|
|
||
| ```text | ||
| Can you find all movies from the 1910s and show their average rating? | ||
| ``` | ||
|
|
||
|  | ||
|
|
||
| ## What you can do | ||
|
|
||
| With your MongoDB connection established, your agent can: | ||
|
|
||
| - **Query documents** with complex filters and projections | ||
| - **Insert, update, and delete** documents | ||
| - **Perform aggregations** for data analysis and reporting | ||
| - **Work with embedded documents** and arrays | ||
| - **Execute transactions** for multi-document operations | ||
| - **Create indexes** for improved query performance | ||
| - **Integrate with other tools** like GitHub, Slack, and Stripe | ||
|
|
||
| ## Best practices | ||
|
|
||
| 1. **Schema design**: Design your document structure to match your query | ||
| patterns | ||
| 2. **Indexing**: Create indexes on frequently queried fields | ||
| 3. **Connection management**: Use connection pooling for better performance | ||
| 4. **Error handling**: Your agent will handle common database errors gracefully | ||
| 5. **Data validation**: Consider using MongoDB schema validation for data | ||
| consistency | ||
|
|
||
| ## Advanced operations | ||
|
|
||
| ### Aggregation pipelines | ||
|
|
||
| Your agent can perform complex aggregation operations: | ||
|
|
||
| ```text | ||
| Can you group movies by decade and show the count and average rating for each decade? | ||
| ``` | ||
|
|
||
| ### Text search | ||
|
|
||
| Enable text search on your collections: | ||
|
|
||
| ```text | ||
| Can you find all movies that mention "robot" in their title or description? | ||
| ``` | ||
|
|
||
| ### Geospatial queries | ||
|
|
||
| For location-based data: | ||
|
|
||
| ```text | ||
| Find all movie theaters within 10 miles of coordinates [40.7128, -74.0060] | ||
| ``` | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Common connection issues | ||
|
|
||
| 1. **Network access**: Ensure your IP is whitelisted in MongoDB Atlas | ||
| 2. **Authentication**: Verify your username and password are correct | ||
| 3. **Connection string**: Check that your connection string format is valid | ||
| 4. **Database permissions**: Ensure your user has appropriate read/write | ||
| permissions | ||
|
|
||
| ### Performance optimization | ||
|
|
||
| 1. **Query optimization**: Use explain() to analyze query performance | ||
| 2. **Index usage**: Monitor index usage and create appropriate indexes | ||
| 3. **Document size**: Keep documents reasonably sized for better performance | ||
| 4. **Connection pooling**: Configure appropriate connection pool settings | ||
|
|
||
| ## Learn more | ||
|
|
||
| - [MongoDB Documentation](https://docs.mongodb.com/) | ||
| - [MongoDB Atlas Documentation](https://docs.atlas.mongodb.com/) | ||
| - [MongoDB Query Language](https://docs.mongodb.com/manual/tutorial/query-documents/) | ||
| - [Aggregation Framework](https://docs.mongodb.com/manual/aggregation/) | ||
|
|
||
| <Tip> | ||
| Combine MongoDB with other Hypermode connections to build powerful workflows. | ||
| For example, use GitHub to track code changes that affect your data models, or | ||
| Slack to notify your team of important database updates and analytics | ||
| insights. | ||
| </Tip> | ||
|
|
||
| ## Example workflows | ||
|
|
||
| ### E-commerce integration | ||
|
|
||
| ```text | ||
| Track inventory levels and automatically update product availability when stock changes | ||
| ``` | ||
|
|
||
| ### Content management | ||
|
|
||
| ```text | ||
| Manage blog posts, user comments, and media assets with flexible document structures | ||
| ``` | ||
|
|
||
| ### Analytics and reporting | ||
|
|
||
| ```text | ||
| Generate real-time reports on user behavior, sales metrics, and application performance | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,7 @@ GraphRAG | |
| [Hh]ypercategories | ||
| [Hh]ypermode | ||
| HNSW | ||
| [Hh]ostname | ||
| Hyperbrowser | ||
| [Ii]nferencing | ||
| Jira | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.