diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/services/waybills.service.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/services/waybills.service.ts b/src/services/waybills.service.ts index 7aea1e3..0744bee 100644 --- a/src/services/waybills.service.ts +++ b/src/services/waybills.service.ts @@ -1,10 +1,33 @@ import { Application } from '@feathersjs/express'; import service from 'feathers-mongoose'; +import { populate } from 'feathers-hooks-common'; import Model from '../models/waybill/waybill.model'; const waybills = service({ Model }); +const populateSchema = { + include: [ + { + service: 'contractors', + nameAs: 'contractor', + parentField: 'contractorId', + childField: '_id' + }, + { + service: 'products', + nameAs: 'product', + parentField: 'productId', + childField: '_id' + }, + ] +}; + export default (app: Application): void => { app.use('/waybills', waybills); + app.service('waybills').hooks({ + after: { + all: populate({ schema: populateSchema }), + }, + }) }; |