connecting nodejs & mongodb

14
By C . Enoch Joshua

Upload: enoch-joshua

Post on 09-Apr-2017

160 views

Category:

Software


17 download

TRANSCRIPT

Page 1: Connecting NodeJS & MongoDB

ByC . Enoch Joshua

Page 2: Connecting NodeJS & MongoDB

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}, }

Page 3: Connecting NodeJS & MongoDB

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

Page 4: Connecting NodeJS & MongoDB

Creating and closing a connection to a Mongo DB

Page 5: Connecting NodeJS & MongoDB

Querying for data in a Mongo Db

Page 6: Connecting NodeJS & MongoDB

OUTPUT

Page 7: Connecting NodeJS & MongoDB

Inserting documents in a collection

Page 8: Connecting NodeJS & MongoDB

Updating documents in a collection

Page 9: Connecting NodeJS & MongoDB

Deleting documents in a collection 

Page 10: Connecting NodeJS & MongoDB

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

Step 1)

Page 11: Connecting NodeJS & MongoDB

Step 2)

Page 12: Connecting NodeJS & MongoDB

Step 3)

Page 13: Connecting NodeJS & MongoDB

Output:

Page 14: Connecting NodeJS & MongoDB

THANK YOU