Querying posts of users followed by current user

I have these 2 Mongoose models in my app, namely User and Post. Users can follow other users, create/read/update/delete posts. On one of the routes, the logged in user (got the authorization part figured out already) should get all posts which were created by users he follows.

Here are the relevant portions of the User...

var UserSchema = new Schema({
    username: String,
    email: String,
    password: String,
    posts: [{
        type: Schema.Types.ObjectId,
        ref: 'Post'
    }],
    following: [{
        type: Schema.Types.ObjectId,
        ref: 'User'
    }]
});

...and the Post model.

var PostSchema = new Schema({
    title: String,
    summary: String,
    body: String,
    author: [{
        type: Schema.Types.ObjectId,
        ref: 'User'
    }]
});

Basically I want to retrieve all Posts, which's author is contained in req.user.following.

I tried finding the posts like this:

Post.find({ author: req.user.following }).exec(function(err, posts){
    // handling results, etc
});

But, of course, it didn't work. I've been thinking of implementing this as I would in a PHP/MySQL environment, like creating another model for followings, which would store who follows who, but I'd probably still run into some problems just like above.

As a beginner at Node.js (and MongoDB too, in fact), I would really appreciate if you could please give me some pointers about how should I do this the node way, or even if you could just point out some aspects of my code which could be made better. Thanks!

You're close, you just need to use the $in operator:

Post.find({ author: { $in: req.user.following }}).exec(function(err, posts){
    // handling results, etc
})

Your existing query is looking for an exact match between the two arrays.