-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Failed to exclude properties by setting false in fields
filter via url
#4992
Comments
@agnes512, could you please add acceptance criteria? Thanks. |
Note: stringified JSON works well e.g |
@agnes512 @raymondfeng The code above, for example, accepts both arrays and objects as arguments but misbehaves if Should there be a normalization step somewhere? |
I checked But I didn't know it accepts arrays. I thought |
I think my confusion stems from |
and But as @InvictusMB pointed out, the where builder allows array. And LB3 supports array syntax as well. I am creating a new story to allow array in type |
Created new story for the array fields: #5857 |
Closed as PRs landed. |
Description
From the docs https://loopback.io/doc/en/lb3/Fields-filter.html ( it's the same for LB4), filter
fields
can be set totrue/false
in a query to include/exclude model properties.fields
works with API Explorer and Node. But it couldn't set properties to false (exclude) via url.Current Behavior
For example, model
Order
has three properties:id
,name
, andprice
. To exclude thename
property from the result, as the docs suggested, the query can be written as?filter[fields][name]=false
. But it returns:i.e it includes only the
name
property instead. I checked the filter sent to the controller, it shows that the filter is being converted towhile with API Explorer, the filter is converted to
The wrong type might cause the problem.
In order to make it work with urls, the query needs to be set as
?filter[fields][id]=true&filter[fields][price]=true
The issue might relate to #2208
Expected Behavior
fields
should be able to exclude properties by setting properties to false via url just like what API Explorer/Node does.Acceptance
checkwhere
clause if it has the same issue ( see this).LB4/Working-with-data/fields-filter
page{fields: ['foo', 'bar']}
. Check if array works for fields. Add proper normalization and error checking if needed. (explained in comment Failed to exclude properties by setting false infields
filter via url #4992 (comment))The text was updated successfully, but these errors were encountered: