http://mongoosejs.com/docs/subdocs.html嵌套子文件貓鼬......這是可能
我使用上面的鏈接,以「推」兒童的數據爲父母..
我可以把數據推抱孫子到孩子和家長進入?
CODE
newPatient.EmergencyContacts.push({
emContact_Name: emContact_Name,
emContact_Relation: emContact_Name,
})
newPatient.EmergencyContacts.emContact_Address.push({
emContact_AddressType: emContact_AddressType,
emContact_AddressLine1: emContact_AddressLine1,
emContact_AddressLine2: emContact_AddressLine2,
emContact_City: emContact_City,
emContact_Town: emContact_Town,
emContact_Village: emContact_Village,
emContact_PolicStation: emContact_PolicStation,
emContact_District: emContact_District,
emContact_State: emContact_State,
emContact_PinCode: emContact_PinCode
});
newPatient.EmergencyContacts.emContact_Info.push({
emContact_phone: emContact_phone,
emContact_email: emContact_email
});
SCHEMA
var mongoose = require('mongoose')
, Schema = mongoose.Schema;
var emContactInfoSchema = new Schema({
emContact_Phone: String,
emContact_Email: String,
});
var emContactAddressSchema = new Schema({
emContact_AddressType: String,
emContact_AddressLine1: String,
emContact_AddressLine2: String,
emContact_City: String,
emContact_Town: String,
emContact_Village: String,
emContact_PolicStation: String,
emContact_District: String,
emContact_State: String,
emContact_PinCode: Number,
});
var emContactSchema = new Schema({
emContact_Name: String,
emContact_Relation: String,
emContact_Address: [emContactAddressSchema],
emContact_Info: [emContactInfoSchema],
});
var patientAddressSchema = new Schema({
Patient_addressType: String,
Patient_addressLine1: String,
Patient_addressLine2: String,
Patient_city: String,
Patient_town: String,
Patient_village: String,
Patient_policeStation: String,
Patient_district: String,
Patient_state: String,
Patient_pinCode: Number,
Patient_countryCode: String,
});
var patientContactInfoSchema = new Schema({
Patient_phoneType: String,
Patient_phoneNumber: String,
Patient_emailType: String,
Patient_email: String,
});
var patientSchema = new Schema({
// patient info
Patient_UHID: { type: String, required: true, index: { unique: true } } , // Univesal Health Indentifier - Aadhar in our case
Patient_altUHID: { type: String, required: false, trim: true, index: { unique: false } }, // As per institution or vendor's specifications
Patient_fName: String,
Patient_mName: String,
Patient_lName: String,
Patient_dob: Date,
Patient_age: Number,
Patient_gender: String,
Patient_occupation: String,
Patient_Addresses : [patientAddressSchema],
Patient_ContactInfo: [patientContactInfoSchema],
Patient_insuranceStatus: String,
Patient_allergyStatus: String,
// Emergency Contact info
EmergencyContacts: [emContactSchema],
});
var patient = mongoose.model('patient', patientSchema);
module.exports = {
Patient: patient
}
所以我想知道它是如何possible.Any方向可以理解
你試試...? – robertklep
是的,我試過不工作....所以這就是爲什麼我要問,如果貓鼬支持 –
那麼你是怎樣嘗試,到底是什麼?你能顯示一些代碼嗎? – robertklep