Since Mongo is a NoSQL database, there are no join tables. Relational data instead uses populations. Populations behave like a join table, but are used at call time.
(thumping hip hop music)…- Mongo is a NoSQL database,…so we don't have join tables.…I was talkin' about this earlier,…but we need a way of seeing relational data.…So the solution for this is called population.…You can think of it as join table at call time.…So what does that look like?…So imagine this.…We have a dog schema.…It has a owner,…it's type is ObjectID,…it refers to a person.…Right?…Then we have a person schema.…
It just has a name.…So I make those two models.…I make a dog model, I make a person model.…All this stuff we've done before.…We've done all this so far.…It's not new.…And then what I want to do…is I say dog dot find,…which is giving me all the dogs.…And I call this method called populate.…And then I pass in the property…on the dogs that I want to populate.…In this case I want to populate…the owner fields.…And then I call this method called exec.…Exec is short for execute.…
It will either return a promise…which I'm using in this case,…or it also takes a callback.…A node-style callback, so it's up to you.…
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
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?
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.