-
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
[Q] query service with property in array of objects jsonb #111
Comments
Hi @Nour-DEV, I see ObjectionJS already had a discussion about this in Vincit/objection.js#1133 If you know the item index in the array you want to query, then check the examples here for how to query a JSON field. Using |
I do not know the index. so how to query it ?
can you show me some example code ?
I will check it |
You can find examples in the README and in the test file |
ok . thank you @dekelev |
@Nour-DEV - I'm struggling with the same issue. If you got that working, could you please share how?
I want to query if there is an entry with a specific riderId and status, so I don't know the index. Thanks in advance. |
async fetch() {
const searchId = 126
const searchstatus = 'awaiting_pickup'
const {data} = await api.service('service-name').find({
query: {
jsonArrayField: {$contains: {id: searchId, status: searchStatus}}
}
})
} if you use this library from client you must whitelist the $contains query parameter |
This, unfortunately, didn't work. I have resorted to creating a modifier instead. I don't know whether it's going to have to any performance impact, but I can live with it for a while. |
why ? is there any error show in the logs or in the console ? or the data set returned was empty ? |
The data didn't get filtered. When I used the (0).objectField notation as in the docs, that worked but I really didn't know the index at which the search criteria would occur. |
check the original objectionjs json filtering functions and check the feathers-objection source code . you will find the correct code to use the |
- how to query service rows with property in array of objects in jsonb field from the client ?
- what are the needed flags to be whitelisted in the service options ?
I use :
for example
- how to query by $like, $in, $gt ...... for property in array of objects ?
I need to ask if feathers objection provide some thing like
mongodb subdocument query
The text was updated successfully, but these errors were encountered: