summaryrefslogtreecommitdiff
path: root/src/services/waybills.service.ts
blob: 02ab2ded87c7459d4670d6c244c86d3644b55188 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { Application } from '@feathersjs/express';
import service from 'feathers-mongoose';
import { populate } from 'feathers-hooks-common';
import Model from '../models/transfer/transfer.model';

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 }),
      ],
    },
  })
};