How to Get Started With Neurelo and MongoDB
Anaiya Raisinghani, Guru Kamat6 min read • Published Aug 30, 2024 • Updated Aug 30, 2024
Rate this tutorial
Ready to hit the ground running with less code, fewer database complexities, and easier platform integration? Then this tutorial on navigating the intersection between Neurelo and MongoDB Atlas is for you.
Neurelo is a platform that utilizes AI, APIs, and the power of the cloud to help developers better interact with and manipulate their data that is stored in either MongoDB, PostgreSQL, or MySQL. This straightforward approach to data programming allows developers to work with their data from their applications, improving scalability and efficiency, while ensuring full transparency. The tutorial below will show readers how to properly set up a Neurelo account, how to connect it with their MongoDB Atlas account, how to use Neurelo’s API Playground to manipulate a collection, and how to create complex queries using Neurelo’s AI Assist feature.
Let’s get started!
Our first step is to make sure we have a MongoDB Atlas cluster ready — if needed, learn more about how to create a cluster. Please ensure you have a memorable username and password, and that you have the proper network permissions in place. To make things easier, you can use
0.0.0.0
as the IP address, but please note that it’s not recommended for production or if you have sensitive information in your cluster.Once the cluster is set up, load in the MongoDB sample data. This is important because we will be using the
sample_restaurants
database and the restaurants
collection. Once the cluster is set up, let’s create our Neurelo account if not already created.Access Neurelo’s dashboard and follow the instructions to create an account. Once finished, you will see this home screen.
Initialize a new project by clicking the orange “New” button in the middle of the screen. Fill in each section of the pop-up.
The
Organization
name is automatically filled for you but please pick a unique name for your project, select the Database Engine
to be used (we are using MongoDB), select the language necessary for your project (this is optional since we are not using a language for this tutorial), and then fill in a description for future you or team members to know what’s going on (also an optional step).Once you click the orange “Create” button, you’ll be shown the three options in the screenshot below. It’s encouraged for new Neurelo users to click on the “Quick Start” option. The other two options are there for you to explore once you’re no longer a novice.
Click on “Connect Data Source.” Please go to your MongoDB Atlas cluster and copy the connection string to your cluster. When putting in your Connection String to Neurelo, you will need to specify the database you want to use at the end of the string. There is no need to specify which collection.
Since we are using our
sample_restaurants
database for this example, we want to ensure it’s included in the Connection String. It’ll look something like this:1 mongodb+srv://mongodb:<password>@cluster0.xh8qopq.mongodb.net/sample_restaurants
Once you’re done, click “Test Connection.” If you’re unable to connect, please go into MongoDB Atlas’ Network permissions and copy in the two IP addresses on the
New Data Source
screen as it might be a network error. Once “Test Connection” is successful, hit “Submit.”Now, click on the orange “New Environment” button. In Neurelo, environments are used so developers can run their APIs (auto-generated and using custom queries) against their data. Please fill in the fields.
Once your environment is successfully created, it’ll turn green and you can continue on to creating your Access Token. Click the orange “New Access Token” button. These tokens grant the users permission to access the APIs for a specific environment.
Store your key somewhere safe — if you lose it, you’ll need to generate a new one.
And congratulations! You have successfully created a project in Neurelo.
Now we can play around with the documents in our MongoDB collection and actually filter through them using the Playground.
In your API Playground “Headers” area, please include your Token Key in the
X-API-KEY
header. This makes it so you’re properly connected to the correct environment.Now you can use Neurelo’s API playground to access the documents located in your MongoDB database.
Let’s say we want to return multiple documents from our restaurant category. We want to return restaurants that are located in the borough of Brooklyn in New York and we want those restaurants that serve American cuisine.
To utilize Neurelo’s API to find us five restaurants, we can click on the “GET Find many restaurants” tab in our “restaurants” collection in the sidebar, click on the
Parameters
header, and fill in our parameters as such:1 select: {"id": true, "borough": true, "cuisine": true, "name": true}
1 filter: {"AND": [{"borough": {"equals": "Brooklyn"}, "cuisine": {"equals": "American"}}]}
1 take: 5
Your response should look something like this:
1 { 2 "data": [ 3 { 4 "id": "5eb3d668b31de5d588f4292a", 5 "borough": "Brooklyn", 6 "cuisine": "American", 7 "name": "Riviera Caterer" 8 }, 9 { 10 "id": "5eb3d668b31de5d588f42931", 11 "borough": "Brooklyn", 12 "cuisine": "American", 13 "name": "Regina Caterers" 14 }, 15 { 16 "id": "5eb3d668b31de5d588f42934", 17 "borough": "Brooklyn", 18 "cuisine": "American", 19 "name": "C & C Catering Service" 20 }, 21 { 22 "id": "5eb3d668b31de5d588f4293c", 23 "borough": "Brooklyn", 24 "cuisine": "American", 25 "name": "The Movable Feast" 26 }, 27 { 28 "id": "5eb3d668b31de5d588f42949", 29 "borough": "Brooklyn", 30 "cuisine": "American", 31 "name": "Mejlander & Mulgannon" 32 } 33 ] 34 }
As you can see from our output, the
select
feature maps to our MongoDB $project
operator. We are choosing which fields from our document to show in our output. The filter
feature mimics our $match
operator and the take
feature mimics our $limit
operator. This is just one simple example, but the opportunities truly are endless. Once you become familiar with these APIs, you can use these APIs to build your applications with MongoDB.Neurelo truly allows developers to easily and quickly set up API calls so they can access and interact with their data.
If we have a use case where Neurelo’s auto-generated endpoints do not give us the results we want, we can actually create complex queries very easily in Neurelo. We are able to create our own custom endpoints for more complex queries that are necessary to filter through the results we want. These queries can be aggregation queries, find queries, or any query that MongoDB supports depending on the use case. Let’s run through an example together.
Access your Neurelo “Home” page and click on the project “Test” we created earlier. Then, click on “Definitions” on the left-hand side of the screen and click on “Custom Queries.”
Click on the orange “New” button in the middle of the screen to add a new custom query endpoint and once the screen pops up, come up with a unique name for your query. Mine is just “complexQuery.”
With Neurelo, you can actually use their AI Assist feature to help come up with the query you’re looking for. Built upon LLMs, AI Assist for complex queries can help you come up with the code you need.
Click on the multicolored “AI Assist” button on the top right-hand corner to bring up the AI Assist tab.
Type in a prompt. Ours is:
“Please give me all restaurants that are in Brooklyn and are American cuisine.”
You can also update the prompt to include the projections to be returned. Changing the prompt to
“get me all restaurants that are in Brooklyn and serve the American cuisine and show me the name of the restaurant” will come up with something like:
As you can see, AI Assist comes up with a valid complex query that we can build upon. This is incredibly helpful especially if we aren’t familiar with syntax or if we just don’t feel like scrolling through documentation.
Edit the custom query to better help with your use case.
Click on the “Use This” button to import the query into your Custom Query box. Using the same example as before, we want to ensure we are able to see the name of the restaurant, the borough, and the cuisine. Here’s the updated version of this query:
1 { 2 "find": "restaurants", 3 "filter": { 4 "borough": "Brooklyn", 5 "cuisine": "American" 6 }, 7 "projection": { 8 "_id": 0, 9 "name": 1, 10 "borough": 1, 11 "cuisine": 1 12 } 13 }
Click the orange “Test Query” button, put in your Access Token, click on the environment approval button, and click run!
Your output will look like this:
1 { 2 "data": { 3 "cursor": { 4 "firstBatch": [ 5 { 6 "borough": "Brooklyn", 7 "cuisine": "American", 8 "name": "Regina Caterers" 9 }, 10 { 11 "borough": "Brooklyn", 12 "cuisine": "American", 13 "name": "The Movable Feast" 14 }, 15 { 16 "borough": "Brooklyn", 17 "cuisine": "American", 18 "name": "Reben Luncheonette" 19 }, 20 { 21 "borough": "Brooklyn", 22 "cuisine": "American", 23 "name": "Cody'S Ale House Grill" 24 }, 25 { 26 "borough": "Brooklyn", 27 "cuisine": "American", 28 "name": "Narrows Coffee Shop" 29 }, 30 …
As you can see, you’ve successfully created a complex query that shows you the name of the restaurant, the borough, and the cuisine. You can now commit and deploy this as a custom endpoint in your Neurelo environment and call this API from your applications. Great job!
This tutorial has successfully taken you through how to create a Neurelo account, connect your MongoDB Atlas database to Neurelo, explore Neurelo’s API Playground, and even create complex queries using their AI Assistant function. Now that you’re familiar with the basics, you can always take things a step further and incorporate the above learnings in a new application.
Top Comments in Forums
There are no comments on this article yet.