A very basic node web app that uses mongoDb. This example demonstrates a fully functional MVC driven solution.
- Install all the node packages.
npm install
- Spin up docker containers for mongoDb and mongo-express (Web-based MongoDB admin interface).
docker-compose up --build
- Connect to mongo client with root access to admin db
docker exec -it mongodb bash
mongo -u root -p example --authenticationDatabase admin
For quick mongo shell command references visit https://docs.mongodb.com/manual/reference/mongo-shell/
- Create a database
use mydatabase
- Create a user and assign read write role to mydatabase
db.createUser(
{
user: "lorem",
pwd: "ipsum",
roles: [
{ role: "readWrite", db: "mydatabase" }
]
}
)
- Run the node app
nodemon app
Enjoy!