Skip to content

Commit

Permalink
EDF: [premieroctet#120] add orderTickets field to order schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Bastien-Wappizy committed Dec 17, 2024
1 parent fdd9aa6 commit 84a286f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions backend/web/server/plugins/entreprisedufutur/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 84a286f

Please sign in to comment.