From the course: Learning MongoDB

Unlock the full course today

Join today to access over 23,400 courses taught by industry experts.

Solution: Avoiding joins

Solution: Avoiding joins - MongoDB Tutorial

From the course: Learning MongoDB

Solution: Avoiding joins

(upbeat techno music) - [Instructor] So how did you do? This challenge might have been a little bit harder but hopefully the solution you came up with was actually pretty simple and elegant. Here's one way we could have solved this. Using our three different data sources, first, we'll create a document that has the user ID, the first name, last name, email, and backing level here on line six. Then, we're going to add a couple different combinations of the objects and arrays. To get the shipping address, we're going to have an object that has all the shipping address information inside it. And for rewards, since there could be more than one, we're going to have an array. So in this case, the person got a book and a beach towel. Why we gave them beach towels, I have no idea. Take a look at the shipping address real quick. Since we're only going to ship to them once, there's no real reason to sh -- to store this in a…

Contents