mongodb command for mongoose populate code example
Example 1: how to use mongoose populate
function getUserWithPosts(username){ return User.findOne({ username: username }) .populate('posts').exec((err, posts) => { console.log("Populated User " + posts); })}
Example 2: how to use mongoose populate
{ _id: 59ab1c92ea84486fb4ba9f28, username: JD, posts: [ "59ab1b43ea84486fb4ba9ef0", "59ab1b43ea84486fb4ba9ef1" ]}