node.js - Multiple one-to-many relationship on mongoose -


i'm using mongoose store 3 models of documents, have update references between then, i'm using mongoose-relationship plugin, need reference this:

  • one customer have many schedules,
  • one costumer have many orders,
  • one order have many schedules

when create order need push schedules id's order reference then. can reference 1 childpath per collection, models mapped this;

customers:

var customerschema = new schema({     name: {type: string, required: true},     email: {type: string, required: true},     shedules: [{ type:mongoose.schema.types.objectid, ref:"schedule" }],     orders: [{ type:mongoose.schema.types.objectid, ref:"order" }] } 

schedules:

var scheduleschema = new schema({     customer: {type:mongoose.schema.types.objectid, ref:"customer", childpath:"shedules"}, //shedule id     order: {type:mongoose.schema.types.objectid, ref:"order", childpath:"shedules"}, //order id     sequence: {type: number, default: 0},     creation_date: {type: date, default: date.now} } sheduleschema.plugin(relationship, {relationshippathname:['customer','order']}); 

orders:

var orderschema = new schema({     customer: {type:mongoose.schema.types.objectid, ref:"customer", childpath:"order"},     shedules: [{type:mongoose.schema.types.objectid, ref:"shedule" }],// <-- field doesn't update.     price: {type: number, default: 0} } orderschema.plugin(relationship, { relationshippathname:'customer' });