Thursday, July 13, 2017

19/06/2017


ExpressJS – Routing

💙Routing function is used to define routes in an Express application.
              
💙app.method(path, handler)
          This method can be applied to any one of the HTTP verbs – get, set, put, delete. 
          Path is the route at which the request will run.
          Handler is a callback function that executes when a matching request type is found on the relevant route.


ExpressJS – HTTP Methods

HTTP methods:

     1.GET
     
     2.POST

     3.PUT

     4.DELETE


ExpressJS – Middleware


💙These functions are used to modify req and res objects for tasks like parsing request bodies, adding response headers, etc.



Updating Documents

💙Mongoose provides 3 functions to update documents. The functions are described below:

1.Model.update(condition, updates, callback)

2.Model.findOneAndUpdate(condition, updates, callback)

3.Model.findByIdAndUpdate(id, updates, callback)
         💙This function updates a single document identified by its id.


Deleting Documents

1.Model.remove(condition, [callback])

2.Model.findOneAndRemove(condition, [callback])

3.Model.findByIdAndRemove(id, [callback])
        💙This function removes a single document identified by its id.


ExpressJS – Cookies

❤Every time the user loads the website back, this cookie is sent with the request.
 💙This helps us keep track of the user’s actions.

💙The following are the numerous uses of the HTTP Cookies:
1.Session management
2.Personalization
3.User tracking



No comments:

Post a Comment

HTML introduction

HTML stands for Hyper Text Markup Language. HTML describes the structure of web page using markup. HTML elements are the building blo...