Skip to content

Commit

Permalink
sosynpl project - [premieroctet#176] add expertise_count to customerF…
Browse files Browse the repository at this point in the history
…reelanceSchema
  • Loading branch information
Batiste1998 committed Sep 11, 2024
1 parent 476dc21 commit 5cc3f65
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions backend/web/server/plugins/sosynpl/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ FREELANCE_MODELS.forEach(model => {
options: { ref: 'certification' }
},
})
declareVirtualField({model, field: 'expertises_count', instance: 'Number', requires: 'expertises'})
declareVirtualField({model, field: 'trainings', instance: 'Array', multiple: true,
caster: {
instance: 'ObjectID',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,13 @@ CustomerFreelanceSchema.virtual('certifications', {
foreignField: 'user',
})

CustomerFreelanceSchema.virtual('expertises_count', {
ref: 'expertise',
foreignField: '_id',
localField: 'expertises',
count: true,
})

CustomerFreelanceSchema.virtual('trainings', {
ref: 'training',
localField: '_id',
Expand Down

0 comments on commit 5cc3f65

Please sign in to comment.