AspNetMicroservices
-
To Download
> docker pull rtsp/mongosh
-
To Run For Local PC Port
>docker run -d -p [portNumber]:[portNumber] --name [containerName] [imageName]
>docker run -d -p 27017:27017 --name shopping-mongo rtsp/mongosh
-
To See Logs
> docker logs -f shopping-mongo
-
Interactive Terminal - Bash Command
> docker exec -it shopping-mongo /bin/bash
If bash is not have, should run this codes:apt-get update
apt-get install -y mongodb
*OR*docker exec -it shopping-mongo mongosh
-
Create DB
> mongo
> use CatalogDb
To create collection: > db.createCollection('Products')
To Add Data:
db.Products.insertMany([{'Name':'Asus Laptop','Category':'Computers', 'Summary':'Summary', 'Description':'Description', 'ImageFile':'ImageFile', 'Price':54.56},{'Name':'HP Laptop','Category':'Computers', 'Summary':'Summary', 'Description':'Description', 'ImageFile':'ImageFile', 'Price':66.56}])
To list data: > db.Products.find({}).pretty()
To delete datas: > db.Products.remove({})
-
To Show DB: >show databases
To Show Collections: >show collections