最佳答案
如果我有两个模式,比如:
var userSchema = new Schema({
twittername: String,
twitterID: Number,
displayName: String,
profilePic: String,
});
var User = mongoose.model('User')
var postSchema = new Schema({
name: String,
postedBy: User, //User Model Type
dateCreated: Date,
comments: [{body:"string", by: mongoose.Schema.Types.ObjectId}],
});
我试着像上面的例子一样把它们连接起来,但是我不知道怎么做。最终,如果我能做这样的事情,它会使我的生活非常容易
var profilePic = Post.postedBy.profilePic