Skip to content

Instantly share code, notes, and snippets.

@anharathoi
Last active December 14, 2019 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anharathoi/d163f0c331625811860a4f4b52ccd36f to your computer and use it in GitHub Desktop.
Save anharathoi/d163f0c331625811860a4f4b52ccd36f to your computer and use it in GitHub Desktop.
mongoDB_atlas

MongoDB atlas

MongoDB Atlas is a fully-managed cloud database developed by the same people that built MongoDB. Atlas handles all the complexity of deploying, managing, and healing your deployments on the cloud service provider of your choice (AWS, Azure, and GCP). Follow the links below to get started.

Create an account

https://www.mongodb.com/cloud/atlas

Go through these steps

  • steps
  1. Build your first cluster: create cluster
  • at the moment, free tier cluster is not available in Australia. The nearest free one should be Singapore, so I recommend selecting Singapore(ap-southeast-1)
  • give your cluster a name and hit the create cluster button.
  1. Create database user create-user

  2. Whitelist your IP address whitelist-ip

  3. Connect to you cluster: connect

  • copy the link and in your express app, add this link instead of the local mongodb link. Replace the <password> bit with your database user password.
  1. connect your application:
    const mongoPROD_URI ="mongodb+srv://username:yourpassword@cluster0-nzlan.mongodb.net/test?retryWrites=true&w=majority"
    
     mongoose.connect(mongoPROD_URI, { useNewUrlParser: true }, (err) => {
       if(err) return console.log(`${err}`)
       console.log("connected to mongodb")
     })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment