13 mongoose

12
Mongoose Ahmed Elbassel Email: [email protected] Skype: ahmed_elbassel

Upload: ahmed-elbassel

Post on 21-Apr-2017

77 views

Category:

Engineering


0 download

TRANSCRIPT

Page 1: 13 mongoose

MongooseAhmed Elbassel

Email: [email protected]

Skype: ahmed_elbassel

Page 2: 13 mongoose

Mongoose- What is Mongoose?- Mongoose datatypes- Creating Schema- Creating models- Connecting to MongoDB- Let’s play a little with Models - CRUD Operations- Managing schema and models as professional- Exercise- Populating Objects

Page 3: 13 mongoose

- Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment.

1. What is Mongoose?

- Alternative:- Mongolia

Page 5: 13 mongoose

Creating Schema

Page 6: 13 mongoose

Creating Models

Page 7: 13 mongoose

Connecting to MongoDB

Page 8: 13 mongoose

Let’s play a little with models - CRUD

Page 9: 13 mongoose

Managing schema and models as professional- Define schema in a separate file and

expose the model of this schema.- Create a model and add your functions that

get data from the database.

Page 10: 13 mongoose

Exercise- Extend your CRUD app in express session to store the data in mongodb in a

the professional way.- Let the user schema has type and views properties:

- If the type is manager then increment the views with 1.

Page 11: 13 mongoose

Populating Objects- Mongoose is lazy load by default, you have to tell it to get the nested foreign

keys.

Page 12: 13 mongoose

Questions