Search code examples
javascriptfeathersjsfeathers-hook

Use feathers-common-hook's populate in before hook


Is it possible to use populate/fastjoin as before hook?

enter image description here

The exact need: I have two services users and user-statuses.

// Models looks like this 
const users = {
    id: number,
    name: string
}

const user-statuses = {
    userId: number,
    status: string
}

I want to get all users with status 'invited':

app.service('users').find({
    query: {
        status: 'invited'
    }
})

How I need to setup populate/fastjoin if it possible to solve this?

(I use feathers-sequelize and know about it's include mechanism. It can do this.)


Solution

  • No possibility to do it by feathers-common-hook lib, but joinQuery from feathers-fletching solve this problem. Correct request with fletching will look like this:

    app.service('users').find({
      query: {
        'user_status.status': 'invited'
      }
    });