/mongo-simple-crud

Docker-compose of mongo db and mongo express.

👌 How to use

  1. Install docker and docker-compose
  2. Download this repository
  3. Enter in the path that have the docker-compose.yml file
  4. Execute this command docker-compose up -d
  5. Go to localhost in your browser and see the magic 😮

🏃 Create database and the CRUD

Create database and let prepared for create the CRUD

All commands are used in terminal

  1. Connect in mongo container: docker exec -it mongo-db bash
  2. Login with your credentials: mongo --username root --password root
  3. Create the database: use db-class

Make the CRUD

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

  1. Create/Insert: db.users.insert({name: "Felipe", age: 23, genre: "Male"})
  2. Read: db.users.find( {} )
  3. Update: db.users.updateOne({name: "Felipe Schossler"}, {$set: {name: "Felipe Schossler", age: 30}})
  4. Delete: db.users.deleteOne({name: "Felipe Schossler"})

🔎 How I create this file

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.