diff options
Diffstat (limited to 'src/services/transfers.service.ts')
-rw-r--r-- | src/services/transfers.service.ts | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/services/transfers.service.ts b/src/services/transfers.service.ts new file mode 100644 index 0000000..cf6a490 --- /dev/null +++ b/src/services/transfers.service.ts @@ -0,0 +1,32 @@ +import { Application } from '@feathersjs/express'; +import service from 'feathers-mongoose'; +import { populate } from 'feathers-hooks-common'; +import Model from '../models/transfer/transfer.model'; +import formatDate from '../hooks/formatDate'; + +const transfers = service({ Model }); + +const populateSchema = { + include: [ + { + service: 'contractors', + nameAs: 'contractor', + parentField: 'contractorId', + childField: '_id' + } + ] +}; + +export default (app: Application): void => { + app.use('/transfers', transfers); + + app.service('transfers').hooks({ + after: { + all: [ + populate({ schema: populateSchema }), + formatDate(), + ], + }, + }) +}; + |