User with favourites and likes system in Mongoose schemas User with favourites and likes system in Mongoose schemas mongoose mongoose

User with favourites and likes system in Mongoose schemas


Your problem is not with the query you're making. there is no foundUser.library because one was never added.

You're adding users to libraries, but you're not adding libraries to your users. if you run the following code in your app:

Library.find({}).populate("user").exec(function(err, foundLibraries){    if (err){        console.log(err);    } else {        console.log(foundLibraries);    }});

You would see that the libraries have their "user" properties, that when populated contain the entire user document as an object. But, the reason that isn't working for foundUser.library when you query for users is that foundUser.library was never assigned. you know how you're assigning the email, username and password when creating users, you have to do the same for the library property. Or, in your case, since a library is only created after the user, you can just set the value of user.library in the callback of creating/saving the library.