I would like to return the count of an embedded collection in a query in mongodb.
Say I have a collection called profiles
var ProfileSchema = new Schema({
  uname: {
    type: String,
    required: true,
    index: true,
    unique: true
  },
  fname: String,
  lname: String,
  posts: [ObjectId]
}); 
How can I query it so that I select uname, frame, lame, posts.length ? I don't want to return the posts collection over the wire since users can have hundreds of posts. Should I even embed the post ids in the profile schema? Maybe I should just get rid of it since there is already another collection defined for posts, so I'm essentially using Profile.posts as an embedded collection of foreign keys.