Tuesday, September 26, 2017

Working With Postman and Nosql Mongodb.

Today i will show you how to push data into Mongodb database using Postman which is a rest api interaction tool.

First of all mongdb must be installed on system using

  • npm install -g mongoose
  • or sudo apt-get install -g mongoose (for ubuntu/linux)
After successfully installing mongoose then we need to create a schema to make a collection in the db. 


This creates a collection with title and url fields. Now we need to install postman which is available in chrome extension as well as in exe format. After installing open the postman, it should look something like this.




We need to make a server with node js which will talk with the mongodb server and listen to port 3000 and then do the POST operations.


Now go back to terminal and switch on mongodb by  typing "mongod" in terminal and press enter.

Observe the mongo server starts running.



Now go to postman and change the type of the operation to POST and the link to localhost/movie where the database is hosted.
Here we will talk with the database and add some data into the db using postman, so now go to the x-form-urlencoded option and then add key and value of title and url which are the data we want to push into the database like this -


Now press send to do the post operation and observe body sent from the server containing the sent data.
Go to localhost and try visiting the link and observe the data is now existing in database thus confirming the post data push from postman is successful.

P.S. This is a MEAN stack project which is used as an example to show the utility of postman for data pushing into mongodb using post method.

No comments: