Minimal Viable Product (MVP) example demos showing how to push data into mongo from node with mongoose. Built for my dev team to pick up.
- install the heroku cli
- cd into the folder of the app
- initialize git
git init
- add the remote
heroku git:remote -a <remote name>
- to push
git push heroku master
-
go to mlab.com and sign up
-
you will need to make a first user, please make note of the username and password
-
hit "create new" database button
-
select aws, single node, free
-
click on the line item for the new DB and enter the page for it, then create a new user for it
-
make a copy of the line "To connect using a driver via the standard MongoDB URI" and paste in dbconnect.js move the username and password values to keys.js
Things you will need username 'aaa'
password 'bbb'
mongodb://aaa:bbb@ds012300.mlab.com:12300/myfilms
keys.js should be in the top level and look like this
module.exports = {
// put all security passwords usernames and keys here and DO NOT commit this file
// keys.js is listed in the .gitignore
mongo : {
username : 'aaa',
password : 'bbb'
}
}
Having the username and password for mongo in keys.js is annoying because the .gitignore will also prevent this file from being committed and pushed to heroku. Possibly another way would be to place them as environment variables that are used if keys.js is missing.