diff --git a/backend/web/server/plugins/entreprisedufutur/functions.js b/backend/web/server/plugins/entreprisedufutur/functions.js index 1b21016f7..c8ba42dfa 100644 --- a/backend/web/server/plugins/entreprisedufutur/functions.js +++ b/backend/web/server/plugins/entreprisedufutur/functions.js @@ -512,6 +512,12 @@ declareComputedField({model: 'admin_dashboard', field: 'partner_list', getterFn: //Order declarations declareEnumField({model: 'order', field:'status', enumValues: ORDER_STATUSES}) +declareVirtualField({model: 'order', field: 'order_tickets', multiple: true, instance: 'Array', + caster: { + instance: 'ObjectID', + options: { ref: 'orderTicket' } + } +}) //OrderTicket declarations declareEnumField({model: 'orderTicket', field: 'status', enumValues: USERTICKET_STATUSES}) diff --git a/backend/web/server/plugins/entreprisedufutur/schemas/OrderSchema.js b/backend/web/server/plugins/entreprisedufutur/schemas/OrderSchema.js index 4d07ed091..18f2e4fed 100644 --- a/backend/web/server/plugins/entreprisedufutur/schemas/OrderSchema.js +++ b/backend/web/server/plugins/entreprisedufutur/schemas/OrderSchema.js @@ -18,6 +18,13 @@ const OrderSchema = new Schema({ }, schemaOptions) /* eslint-disable prefer-arrow-callback */ + +OrderSchema.virtual('order_tickets', { + ref: 'orderTicket', + localField: '_id', + foreignField: 'order' +}) + /* eslint-enable prefer-arrow-callback */ module.exports = OrderSchema \ No newline at end of file