Is it possible to exceed Mongodb's document size limit by storing object Id in a single document?

Problem

Suppose we have such a mongodb schema (I used the format from mongoose just for illustration purposes):

var userSchema = new Schema({
    posts : [Schema.Types.ObjectId] // stores the _id field from post
});

var postSchema = new Schema({
    body : String
});

Since the maximum document size in mongodb is 16 MB, which is finite, wouldn't we run the risk of exceeding such a limit such the above schema (even if it is a every small risk ) ?

Thanks.

Problem courtesy of: Jeremy Huang

Solution

Yes, that's possible for a very large number of posts. The traditional way to overcome the limitation is to invert the schema:

var userSchema = new Schema({
    name: String
});

var postSchema = new Schema({
    user: { type: Schema.Types.ObjectId },  // _id of the post's user
    body : String
});
Solution courtesy of: JohnnyHK

Discussion

There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.