Skip to content

support json search #1049

Closed
Closed
@clysss

Description

@clysss

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

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions