让我说我有这个架构:
var PersonSchema = new Schema({
name: Schema.Types.Mixed,
idRdv:{type:Schema.Types.ObjectId, ref: 'Rdv'}
});
另一个架构:
var RdvSchema = new Schema({
_idRdv:{type: Schema.Types.ObjectId},
person:{type: Schema.Types.Mixed, ref:'Person'}
});
var Person= mongoose.model('Person', PersonSchema);
var Rdv = mongoose.model('Rdv',RdvSchema);
当我添加数据时:
var person1= new Person({
Name: 'Jean',
_idRdv: rdv1._idRdv <--- this value isn't defined yet so it won't pass it to mongo
var rdv1 = new Rdv({
_idRdv: new mongoose.Types.ObjectId(),
person: person1.Name
});
当我向这些模式添加数据时,由于患者已在Rdv之前创建,因此患者无法接收_idRdv值存在问题。
有没有办法让_idRdv也被填满?