Schema fields' naming convention for mongoose ODM - dreamerslab/workspace GitHub Wiki
// for example
PostSchema = new Schema({
title : { type : String },
content : { type : String },
is_writable : { type : String },
is_published : { type : Boolean }
});
- Fields to embed structural documents
// for example
var PostSchema = new Schema({
title : { type : String },
content : { type : String },
user : UserSchema,
comments : [ CommentSchema ]
});
- Fields to populate related objects
// for example
var PostSchema = new Schema({
title : { type : String },
content : { type : String },
user : { type : ObjectId },
comments : [{ type : ObjectId}]
});
- Fields to cache corresponding objects
// for example
var PostSchema = new Schema({
title : { type : String },
content : { type : String },
as_user : { type : Schema.Types.Mixed },
as_comments : [{ type : Schema.Types.Mixed}]
});
Note that it seems that in mongoose _plural name to a corresponding model has special usage internally, so it is not a good idea to use _comments as the field name to refer to comments in a post.