Closed bravo-kernel closed 7 years ago
I would prefer if a FoC member would close this issue after confirming but it looks like this is indeed fully supported by using:
filter
like show below public function searchConfiguration()
{
$search = new Manager($this);
$search
->like('filter', [
'before' => true,
'after' => true,
'field' => [$this->aliasField('name'), $this->aliasField('description')]
]);
return $search;
}
Connecting to http://cake3api.app/api/cocktails?filter=beer
filters the results like shown below:
{
"data": [
{
"type": "cocktails",
"id": "8",
"attributes": {
"name": "Black Velvet",
"description": "Beer based",
"created": "2015-04-11T09:52:02+00:00",
"modified": null
},
"links": {
"self": "/api/cocktails/8"
}
}
]
}
Update: adding an Ember Data generated URL with filtering which seems to match information about regarding JSON API filtering out there on the internet. Unsure if this can be matched using the Search plugin though.
/user-profiles?filter[user_id]=1
Multiple filters seem to be possible as well:
GET https://example.com/api/v1/posts
?page[number]=2
&page[size]=50
&sort=author,-created
&fields[posts]=id,title,created
&include=comments,author
&filter[posts]=1,2
&filter[comments]=1,2
&filter[status]=posted
It can if a middleware is written to convert the nested form into a non nested form ☺️
This issue was moved to FriendsOfCake/crud-json-api#4
JSON API Filtering should be fully supported using the FriendsOfCake Search Plugin.
Note: JSON API is agnostic about the strategies supported by a server. The filter query parameter can be used as the basis for any number of filtering strategies.