Scott continues the exercise 9 solution by explaining the get method in the postcontroller and the getOne method in the usercontroller.
(upbeat music)…- So this is my solution…for the Get inside the post controller.…Because Get is just going to get back all the instances…of the collection.…But there's little difference in like how post works…because it has relations, so we have to change it…to slightly different than what's going…on with the other ones.…So what we have to do is we can just call .find…I'm just passing an empty object here,…but if you just want to return back every single one,…I don't, you don't really have to pass it anything.…
I'm just doing this just to be safe,…but you don't have to.…You can just say, just find everything on post.…And then, I call it .populate,…and remember what populate does is,…it's going to go to the fields on this document…who has the type, well, first what it'll do…it won't do anything unless you tell it what fields…to populate, so when you call .populate…and you give it the fields that you want to populate…it will go to these respective fields on the document…and it will grab their object IDs,…cause that's their values, and then it will go…
This course was created by Frontend Masters. It was originally released on 12/30/2015. We're pleased to host this training in our library.
- Executing Node.js
- Using Express
- What is middleware?
- Testing in Node.js
- Using Mongo with Node.js
- Data modeling
- Querying data with Mongoose
- Identifying sensitive routes
- Configuring the deployment
Skill Level Intermediate
Node.js: Build Your First Microservicewith Daniel Khan2h 9m Intermediate
Building APIs Using Hapi in Node.jswith Kirsten Hunter2h 23m Intermediate
Node.js: Extend and Maintain Applicationswith Daniel Khan3h 35m Intermediate
2. REST APIs
5. Organization and Configuration
7. Data Modeling
10. Securing Routes
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.