Connecting NodeJS & MongoDB

Post on 09-Apr-2017

155 Views

Category:

Software

17 Downloads

Preview:

Click to see full reader

Transcript

ByC . Enoch Joshua

INTRODUCTION• Database name: Employee DB• Collection name: Employee

Documents { {Employeeid : 1, Employee Name : joshua}, {Employeeid : 2, Employee Name : enoch}, {Employeeid : 3, Employee Name : enojoe}, {Employeeid : 4, Employee Name : venkat}, {Employeeid : 5, Employee Name : shan}, {Employeeid : 6, Employee Name : iliyas}, {Employeeid : 7, Employee Name : desa}, }

Installing the NPM Modules• To access Mongo from within a Node application, a

driver is required. There are number of Mongo drivers available, but Mongo DB is among the most popular. To install the Mongo DB module, run the below command

• npm install mongo db

Creating and closing a connection to a Mongo DB

Querying for data in a Mongo Db

OUTPUT

Inserting documents in a collection

Updating documents in a collection

Deleting documents in a collection 

How to build a node express app with Mongo DB to store and serve content

Step 1)

Step 2)

Step 3)

Output:

THANK YOU

top related