如果我有两个模式,如:
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