MongoDB is a popular NoSQL database known for its flexibility and scalability. It allows developers to store and manage large amounts of data with ease.
How does the integration work?
You can utilize a pre-built Appwrite function template to integrate a MongoDB Atlas cluster with your app. This will allow you to leverage MongoDB's powerful data management capabilities and NoSQL database and potentially extend it with Appwrite’s ecosystem.
How to implement
To implement the MongoDB Atlas integration, follow these simple steps:
Step 1: Set up a MongoDB database
First, create an account on MongoDB Atlas and deploy your first cluster.
Create your username and password and copy the connection string for your MongoDB Atlas cluster. This connection string will be used to connect the Appwrite Function to your MongoDB cluster.
Next, head to the Network Access page from the left sidebar, click on the Add IP Address button, and allow access from anywhere.
Step 2: Create the Appwrite Function
For this step, you must create an account on Appwrite Cloud or self-host Appwrite if you haven’t already. In case you decide to self-host Appwrite, there are additional setup steps to use Appwrite Function templates.
Head over to the Appwrite console, navigate to the Functions page, click on the Templates tab, and search for the MongoDB function template.
Add the MongoDB connection string you saved in the Variables step. Then, create a new repository with the default branch and root directory settings. You can edit this repository later to update the function logic.
Step 3: Test the function
Once the function is ready, visit the Domains tab on the Functions page and copy the domain URL to test the function. Sending a GET (HTTP) Request to this endpoint will add a randomly generated mock document and list all the documents in the database.
curl DEPLOYED_FUNCTION_DOMAIN \
-H 'accept: application/json'
You can add other database functionalities by editing the function generated for you on GitHub.
Read more about MongoDB Atlas and Appwrite Functions
If you would like to learn more about MongoDB Atlas and Appwrite Functions, we have some resources that you should visit: