Closed jurajpetrik closed 9 years ago
Solved it. You can get it like this
User.findOne({id: userId})
.populate('pets').
.exec(function (err, user){
console.log(user.pets);
})
Good stuff, thanks for sharing @jurajpetrik!
Let's say I have a many to many association like below.
An user can own many pets and a pet can be owned by many users. (I changed the table names to user and pet to go in line with the documentation)
I want to get all pets owned by a certain user. I tried a query like below. My postgresql db returns an error complaining Pet.ownedBy column doesn't exist.