Skip to content
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

support json search #1049

Open
clysss opened this issue Jan 9, 2025 · 0 comments
Open

support json search #1049

clysss opened this issue Jan 9, 2025 · 0 comments

Comments

@clysss
Copy link
Contributor

clysss commented Jan 9, 2025

hello @mevdschee , Happy new year 2025 !
with posgresql, I've a field name data (character varying) containing a json.
suppose this json is {"xxx":"yyy", "zzz":{"www":"sss", "tags":["one", "two", "three"]}}.
I can write
SELECT * FROM public.xxx
WHERE "data"::jsonb ->'zzz'-> 'tags' @> '"two"';
to have the records having tags=two
I'm using a custom controller. Is there a way to make a call to recordService->_list(
with some parameters to create this SQL call ?

I haven't see anything about json select in json middleware and begin to deep into
https://github.com/mevdschee/php-crud-api/blob/main/src/Tqdev/PhpCrudApi/Database/ConditionsBuilder.php

my goal could be something like
GET /records/your_table?filter=data->zzz->tags,js,two
[in fact I just need in my case [filter =>"data->zzz->tags,js,two"] (or even ""data"::jsonb ->'zzz'-> 'tags',js,two )
or perhaps if its easier "data, js,zzz->tags:two"
js would be a new keyword if needed to allow "fake" colum name ("data->zzz->tags") : what do you think about that ??
Thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant