-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Customizing the query #123
Comments
You do have the ability. Use modifiers methods in your model and run them
on queries with $modify.
בתאריך שבת, 17 באוק׳ 2020, 16:18, מאת mikeconley12 <
notifications@github.com>:
… It would be great to have an ability to customize the query. See the Knex
service adapter docs
<https://github.com/feathersjs-ecosystem/feathers-knex#customizing-the-query>
for details
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#123>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABB5E3NEFRXPK7MNAVWWJMDSLGKTBANCNFSM4SULPBZQ>
.
|
Thanks for your answer! I will check the modifiers in a few days and close this issue or explain why it doesn't work. |
Hi @dekelev ! I have a question. I need an equivalent to this: const women = await Person.query()
.modify('filterAge', 18)
.modify('filterGender', 'female'); |
You can add 2 modifiers to the model and when calling find on the service,
add params.query.$modify=modifier1_fn_name,modifier2_fn_name
Check the docs for examples.
בתאריך יום א׳, 18 באוק׳ 2020, 19:07, מאת mikeconley12 <
notifications@github.com>:
… Hi @dekelev <https://github.com/dekelev> ! I have a question.
How can I specify multiple modifiers with different arguments?
I need an equivalent to this:
const women = await Person.query()
.modify('filterAge', 18)
.modify('filterGender', 'female');
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#123 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABB5E3OKDS6G4LVPIVTEDOTSLMHDNANCNFSM4SULPBZQ>
.
|
Passing arguments to modifiers is supported too, but I think you'll need to
use array for that.
בתאריך יום א׳, 18 באוק׳ 2020, 20:01, מאת Dekel <dekelev@gmail.com>:
… You can add 2 modifiers to the model and when calling find on the service,
add params.query.$modify=modifier1_fn_name,modifier2_fn_name
Check the docs for examples.
בתאריך יום א׳, 18 באוק׳ 2020, 19:07, מאת mikeconley12 <
***@***.***>:
> Hi @dekelev <https://github.com/dekelev> ! I have a question.
> How can I specify multiple modifiers with different arguments?
>
> I need an equivalent to this:
>
> const women = await Person.query()
> .modify('filterAge', 18)
> .modify('filterGender', 'female');
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#123 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ABB5E3OKDS6G4LVPIVTEDOTSLMHDNANCNFSM4SULPBZQ>
> .
>
|
yes, I checked the docs. But I need different arguments for each modifier. Is it possible? params.query.$modify = { "modifier1_fn_name": ["args1"], "modifier2_fn_name": ["args2"] }; |
Yes, it's possible
בתאריך יום א׳, 18 באוק׳ 2020, 20:15, מאת mikeconley12 <
notifications@github.com>:
… yes, I checked the docs. But I need different arguments for each modifier.
Is it possible?
params.query.$modify = { "modifier1_fn_name": ["args1"], "modifier2_fn_name": ["args2"] };
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#123 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABB5E3LCKRQ6ZJ6OSPV54TTSLMPB7ANCNFSM4SULPBZQ>
.
|
Check the test file for usage examples.
בתאריך יום א׳, 18 באוק׳ 2020, 20:44, מאת Dekel <dekelev@gmail.com>:
… Yes, it's possible
בתאריך יום א׳, 18 באוק׳ 2020, 20:15, מאת mikeconley12 <
***@***.***>:
> yes, I checked the docs. But I need different arguments for each
> modifier. Is it possible?
>
> params.query.$modify = { "modifier1_fn_name": ["args1"], "modifier2_fn_name": ["args2"] };
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#123 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ABB5E3LCKRQ6ZJ6OSPV54TTSLMPB7ANCNFSM4SULPBZQ>
> .
>
|
Sorry, but I already checked this test file and I didn't find a solution. For example, I see here multiple modifiers, but all the modifiers have the same arguments. |
https://github.com/feathersjs-ecosystem/feathers-objection/blob/0f4a36702a4b134933650afd81d2bafaaa5812f5/test/index.test.js#L2097
Each item in the array is an array that its first item is the modifier name
and rest of items are args for that modifier.
בתאריך יום א׳, 18 באוק׳ 2020, 21:03, מאת mikeconley12 <
notifications@github.com>:
… Sorry, but I already checked this test file
<https://github.com/feathersjs-ecosystem/feathers-objection/blob/master/test/index.test.js>
and I didn't find a solution.
For example, I see here
<https://github.com/feathersjs-ecosystem/feathers-objection/blob/master/test/index.test.js#L2105>
multiple modifiers, but all the modifiers have the same arguments.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#123 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABB5E3NYEYEG4VG47JU673LSLMUWHANCNFSM4SULPBZQ>
.
|
No, in your example, feathers-objection/test/company.js Line 53 in dbd6e44
Also see Objection.js documentation. It says that the first argument is a modifier, and the rest are arguments passed to the modify function |
Right, so I'll add support for JSON object as value for
It's also much more readable in my opinion, so it would also be my default value type for |
It's awesome! Thank you! But will it be a JSON string? Or just a regular JS object? |
It will also support stringified JSON object.
בתאריך יום ב׳, 19 באוק׳ 2020, 13:08, מאת mikeconley12 <
notifications@github.com>:
… It's awesome! Thank you! But will it be a JSON string? Or just a regular
JS object?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#123 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABB5E3PNCCJWKDFCYKG5L5DSLQF2ZANCNFSM4SULPBZQ>
.
|
Released with v6.1.0 I've updated the $modify docs as well. enjoy! |
Great, thanks for your help! |
It would be great to have an ability to customize the query. See the Knex service adapter docs for details
The text was updated successfully, but these errors were encountered: