Database Setup
Connect your ZapStart application to MongoDB Atlas for reliable, scalable data storage.
Introduction
ZapStart uses MongoDB for data storage. MongoDB is a document database that makes it easy to store, query, and index your application data. In this guide, we'll set up MongoDB Atlas, a fully-managed cloud database service.
Setting Up MongoDB Atlas
Let's create a MongoDB Atlas account and project:
- Go to MongoDB Atlas and create an account (or sign in)
- Choose the free tier, region could be N. Virginia (us-east-1) or any other region.
- Create a user database and save the username and password somewhere safe.
- Click on connect or choose a connection method, choose Drivers and then Node.js
- Copy the connection string to your .env file
MONGODB_URI=
, it would look something like this:mongodb+srv://username:password@cluster0.xxxxx.mongodb.net/?retryWrites=true&w=majority
- Replace the username and password with your database user's username and password.
Choose a descriptive name for your project to help you identify it later, especially if you plan to build multiple applications.
Configure Network Access
- Go to Network Access in the left menu
- Click Add IP Address
- For development, select Allow Access from Anywhere (0.0.0.0/0), this allows you to connect to the database from your local computer or from production servers.
- Click Confirm
Keep your database credentials secure! Don't commit them to version control or share them publicly.
Changing the Database Name
By default, MongoDB will use a database named "test". You should change this to a name that reflects your application.
To do this, modify the URI to include your database name before the query parameters:
mongodb+srv://username:password@cluster0.xxxxx.mongodb.net/?retryWrites=true&w=majority
Notice how we added /my-awesome-saas
before the ?
in the URI. This tells MongoDB to use a database named "my-awesome-saas".
For a quick tutorial on database in zapstart, please see the MongoDB Tutorial after setting up your database.
Next Steps
Now that you've configured your JWT secrets and MongoDB, you can continue setting up the rest:
- Configure Google OAuth
- Set up email services
- Integrate payment processing
- Fill in the Config files with the correct values