var conversationSchema = new Schema({
created: { type: Date, default: Date.now },
updated: { type: Date, default: Date.now },
recipients: [{ type: Schema.ObjectId, ref: 'User' }],
messages: [ conversationMessageSchema ]
});
mongoose.model('Conversation', conversationSchema);
在上面的示例中,您将如何在收件人数组中添加额外的属性,例如... status?
即。收件人:
[{ _id: {
type: Schema.ObjectId,
ref: 'User'
},
status {
type: String
}
}]
喜欢这个^?
由于
答案 0 :(得分:-2)
你可以这样做
var conversationSchema = new Schema({
created: { type: Date, default: Date.now },
updated: { type: Date, default: Date.now },
recipients: [
name:{ type: Schema.Types.ObjectId, ref: 'User' },
status { type: String}
],
messages: [ conversationMessageSchema ]
});
mongoose.model('Conversation', conversationSchema);