You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi.
I'm trying to have good results from a call with join and filters.
I have 2 tables: "requests_details" and "requests". For the "requests" table I set the "authorization.recordHandler" middleware to add "filter=user_id,eq,$_SESSION['apiUser']['id']" if the user is not "admin".
The API endpoint is "/records/requests_details?join=requests&filter=request_id,nis".
As for the logic: I can see why the filter doesn't work as the null results are caused by the recordHandler. You can apply an customization.afterHandler if you really want to remove those results from the query. You can also list the requests with their corresponding requests_details instead of the other way around.
I was using that code because I have other conditions for other tables but... my code and your code couldn't be considered very similar?
Anyway I replaced my code with yours but results are the same so I decided to use customization.afterHandler but I cannot find information about it and its parameters. I made the following code: if ($tableName == 'requests_details') { $arr = json_decode($response->getBody()->getContents(), true); $arr['records'] = array_filter($arr['records'], function ($obj) { return !is_null($obj['request_id']); }); return ResponseFactory::fromObject(200, $arr, 1); }
Results are ok but the question is: Is this the right way?
Another question: in authorization.recordHandler I can add only the filter parameter? Is not possible to use others as excludeor join? I tried but it seems not working.
Hi.
I'm trying to have good results from a call with join and filters.
I have 2 tables: "requests_details" and "requests". For the "requests" table I set the "authorization.recordHandler" middleware to add "filter=user_id,eq,$_SESSION['apiUser']['id']" if the user is not "admin".
The API endpoint is "/records/requests_details?join=requests&filter=request_id,nis".
At the moment I have the following response:
For good results I mean those where request_id is not
null
.I set "authorization.recordHandler" additional as following:
Where I'm wrong?
Is there another way to achieve the desired result?
Thanks
The text was updated successfully, but these errors were encountered: