Skip to content

Instantly share code, notes, and snippets.

@nesquena

nesquena/mlab.md Secret

Last active April 18, 2017 07:37
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 nesquena/7786c5a876e335737fb28d037400fd40 to your computer and use it in GitHub Desktop.
Save nesquena/7786c5a876e335737fb28d037400fd40 to your computer and use it in GitHub Desktop.
MongoDB and mLab

Starting your Mongodb(mLab):

After Creating your mLab Account, in Heroku click on Create new button and select Single-node -> Sandbox to get the free Db and give your database a name (I've created a db named 'food' for this as an example) .

Now a database is created with the name 'food',You can create a new collection of your own. A collection in MongoDb is akin to a table in RDMS; it represents one root ParseObject you might persist and update from within your app.

Finally Add a User or Users who can access permissions on this Database. You will not be able to use the automatically generated db user, with the dbOwner role, since you have no access to its correct password. While Adding a user it will ask for username and password which are used to access the Database.

Now your DB is running at url something like this:

mongodb://username:password@ds01316.mlab.com:1316/food/

where username and password are the details that you've given when you added a user. You should use this full, exact url (starting with the mongodb:// protocol, and ending with a '/') as the value of your MONGODB_URL setup variable in Heroku. This will allow the parse-server bridge to bind with that configuration.

You can find your DB url at https://mlab.com/databases/your_database_name101

You can verify whether the objects were created by your Parse API calls by clicking on the MongoDB instance in the Heroku panel and reviewing the data created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment