- Install docker and docker-compose
- Download this repository
- Enter in the path that have the docker-compose.yml file
- Execute this command
docker-compose up -d
- Go to localhost in your browser and see the magic 😮
All commands are used in terminal
- Connect in mongo container:
docker exec -it mongo-db bash
- Login with your credentials:
mongo --username root --password root
- Create the database:
use db-class
You can observe the CRUD operations using mongo-express (a web-based app for mongo) it's just click here. All you need to do is enter in the db-class database
- Create/Insert:
db.users.insert({name: "Felipe", age: 23, genre: "Male"})
- Read:
db.users.find( {} )
- Update:
db.users.updateOne({name: "Felipe Schossler"}, {$set: {name: "Felipe Schossler", age: 30}})
- Delete:
db.users.deleteOne({name: "Felipe Schossler"})
First I check on Docker Hub for mongo image and i found express too.
So I make a compose file for using the mongodb with the best practices and testing if everything is fine.