CRUD operation on MongoDB atlas are performed using this application
Go to the project directory and apply following commands in your terminal.
-
Build using Docker command:
docker build -t .
Ex:- docker build flask-app .
-
Run using Docker command:
docker run it -p 5000:5000
Ex: docker run it -p 5000:5000 flask-app
-
Read all the data from the data in MongoDB atlas.
curl -i -H "Content-Type: application/json" -X GET http://127.0.0.1:5000/show_all_document
Input Screenshot:
Output Screenshot:
-
Read specific data Ex: find the data whose brand_name = '?'.
For Windows:-
curl -i -H "Content-Type: application/json" -X GET -d "{"""brand_name""":"""jellycat"""}" http://127.0.0.1:5000/find_document
For Linux:-
curl -i -H "Content-Type: application/json" -X GET -d "{"brand_name":"jellycat"}" http://127.0.0.1:5000/find_document
Input and Output Screenshot:
-
Insert data. Ex: If you want to add new product,so you must have to provide its name and brand_name ,other fields are not necessary.
For Windows:-
curl -i -H "Content-Type: application/json" -X POST -d "{"""name""":"""jenson-t-series""","""brand_name""":"""jenson"""}" http://127.0.0.1:5000/insert_documents
For Linux:
curl -i -H "Content-Type: application/json" -X POST -d "{"name":"jenson-t-series","brand_name":"jenson"}" http://127.0.0.1:5000/insert_documents
Input Screenshot:
Output Screenshot:
-
Update specific data.Since there is no primary key in the given data,I used brand_name to find and update the data.
For Windows:-
curl -i -H "Content-Type: application/json" -X PUT -d "{"""name""":"""jetson-t-series""","""brand_name""":"""jetson"""}" http://127.0.0.1:5000/update_documents/jenson
For Linux:-
curl -i -H "Content-Type: application/json" -X PUT -d "{"name":"jenson-t-series","brand_name":"jenson"}" http://127.0.0.1:5000/update_documents/jenson
Note:- I am finding the product using brand_name "jenson" and update its name and brand_name.
Input Screenshot:
Output Screenshot:
-
Delete the data Ex: deleting the data using its brand_name.
For Windows:-
curl -i -H "Content-Type: application/json" -X DELETE -d "{"""brand_name""":"""jetson"""}" http://127.0.0.1:5000/delete_documents
For Linux:-
curl -i -H "Content-Type: application/json" -X DELETE -d "{"brand_name":"jetson"}" http://127.0.0.1:5000/delete_documents
Input and Output Screenshot: