Skip to content

Commit

Permalink
Cyberleague: [premieroctet#165] add carreer_applications virtual fiel…
Browse files Browse the repository at this point in the history
…d in user schema
  • Loading branch information
Bastien-Wappizy committed Oct 3, 2024
1 parent 71d3def commit 755f544
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions backend/web/server/plugins/cyberleague/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ USER_MODELS.forEach(m => {
})
declareVirtualField({model: m, field: 'level', requires: 'tokens', instance: 'String', enumValues: USER_LEVELS})
declareComputedField({model: m, field: 'related_users', requires:'function,company.size,company.sector,shortname', getterFn: getRelated('user')})
declareVirtualField({model: m, field: 'carreer_applications', instance: 'Array', multiple: true,
caster: {
instance: 'ObjectID',
options: {ref: 'carreer'}
}
})
})

//Company declarations
Expand Down
6 changes: 6 additions & 0 deletions backend/web/server/plugins/cyberleague/schemas/UserSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,12 @@ UserSchema.virtual('level', DUMMY_REF).get(function() {
return USER_LEVEL_EXPLORER
})

UserSchema.virtual('carreer_applications', {
ref:'carreer',
localField:'_id',
foreignField:'candidates',
})

/* eslint-enable prefer-arrow-callback */

module.exports = UserSchema

0 comments on commit 755f544

Please sign in to comment.