- Getting students details by ID
- Registring new students by supping students details
This is handled by the express app which is being required in the index.js since it is a package/dependency. This was done via the GET request handler. The app.get route and the router.get routes were also used in this project. A callback function is passed right after these parameters to be able to interact with the request and response parameters to render our EJS files on the browser. IDs were automatically generated by the database application(MONGODB).During the retrieval of any of the documents from the database, the id is being passed a parameter to the browser, and hence search through the database to display the extra details of the particular ID(document).
A web form was created in a register.ejs file as part of the project. Throught this form, we take detailed(value) of a student pass it as data and save it to the database and return a template which adds the data passed into the form earlier in addition to the existing data if there is any. This is done by the POST request handler. This is also similarly handled by the app created from the express framer. An object model was created using the mongoose and in conjuction with the mongodb. During the post request, a path is passed as a parameter which directs users to the root of the site(/students). The second argument passed to this fuction is a callback function which takes in the request and response arguments. Within this callback function, an instance of the object is created thus const student = new Student(req.body) and then grabs the values with was passed from the forms and saves it to the database(The student.save() is used for this action).
- EJS
- Express
- Mongoose
- morgan
- NodeMon