我知道如何在Mongoose中使用embed documents,如果将它们存储为数组,它们看起来相当简单,对于这种情况,用例非常明显:
var CommentSchema = new Mongoose.Schema({...});
var BlogPostSchema = new Mongoose.Schema({
comments : [CommentSchema],
});
但是,在向前和向后查看文档之后,我不知道如何存储不需要或不希望位于数组中的单个子文档.
var UserSchema = new Mongoose.Schema({...});
var BlogPostSchema = new Mongoose.Schema({
author: ??? // 'UserSchema' and UserSchema do not work here.
});
有什么办法可以让这一切顺利进行吗?我不想只存储ObjectId,而是存储用户记录的完整副本,但不需要或想要array.