feathersjs-ecosystem / feathers-objection

Feathers database adapter for Objection.js, an ORM based on KnexJS SQL query builder for Postgres, Redshift, MSSQL, MySQL, MariaDB, SQLite3, and Oracle. Forked from feathers-knex.
MIT License
98 stars 48 forks source link

filters without eager queries #86

Closed devashishsethia closed 4 years ago

devashishsethia commented 4 years ago

Hi,

Does feathers-objection support using filters without using it in a eager query? Like how we can do with Objection:

class Person extends Model {
  static modifiers = {
    defaultSelects(query) {
      query.select('id', 'firstName');
    },

    filterGender(query, gender) {
      query.where('gender', gender);
    }
  };
}
const women = await Person.query()
  .modify('defaultSelects')
  .modify('filterGender', 'female');

It would be great if we can pass a $modify query parameter and use static modifiers. Thanks.

dekelev commented 4 years ago

Thanks @devashishsethia , $modify is now supported in the latest version. check the docs for more info.

prashantnirgun commented 3 years ago

Hi to community I am new to it can any one explain how to give call to $modify using post man I want to use this in GET request from postman GET localost:3000/perosn?$modify=filterGender=['gender', 'female'] its considering $modify as a column and adding it to where clause.

devashishsethia commented 3 years ago

I hope you've created the modifier in your model. $modify will be an array, so it will have to be used like ?$modify[]=filterGender&$modify[]=female

Regards, Devashish Sethia

On Mon, Jul 12, 2021 at 12:06 AM Prashant Nirgun @.***> wrote:

Hi to community I am new to it can any one explain how to give call to $modify using post man I want to use this in GET request from postman GET localost:3000/perosn?$modify=filterGender=['gender', 'female'] its considering $modify as a column and adding it to where clause.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/feathersjs-ecosystem/feathers-objection/issues/86#issuecomment-877843568, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEDTWCXCPU432PEC53H3SADTXHQEVANCNFSM4LGFJNGQ .