बिना क्षेत्र को पॉप्युलेट मैं 3 स्कीमा है:नेवला रेफरी विकल्प
var User1Schema = new Schema({
name: {type:String , trim: true, required: true },
status: {type:Number, required: true, default:1}
},{collection:"user_1"});
,
var User2Schema = new Schema({
name: {type:String , trim: true, required: true },
email: {type: String, required: true, index: {unique: true} },
status: {type:Number, required: true, default:1}
},{collection:"user_2"});
और
var ConversationSchema = new Schema({
participants: [{user:{type: ObjectId, required: true}],
creator: {type: ObjectId, required: true},
status: { type:Number, required: true, default:1 }
}, { collection:"conversation" });
ConversationSchema में मैं निर्माता क्षेत्र जो अब रेफरी का विकल्प है, क्योंकि, यह User1chechema या User2Schema का प्रकार हो सकता है।
मैं नेवला
'mongoose-dbref' प्लगइन देखें: https://github.com/goulash1971/mongoose-dbref – JohnnyHK
यहां' mongoose-dbref' की एक और अद्यतित शाखा है https://github.com/apiaryio/नेवला-dbref। हालांकि, यदि संभव हो, तो आपको इसे ब्रांच करने की बजाय अपनी स्कीमा को बदलने की कोशिश करनी चाहिए: http://stackoverflow.com/questions/7617002/dealing-with-schema-changes-in-mongoose – mjhm