-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Suggestion
Follow-up story from #4992 (comment)
Now the fields filter only allow object, like {fields: {title: true, desc: true}}, but doesn't allow the array shortcut like {fields: ['title', 'desc']}.
We should support the array shortcut as well.
Copy the details here:
fields: ['foo', 'bar'] is not allowed with bad request error. The reason is, type Fields<T> only allows object, so that type Filter<T> can only have fields as object. Array is now accepted. See:
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 Fields<T>. We can move the further discussion there.
Use Cases
Filter with fields as array: {fields: ['title', 'desc']}
Examples
Filter with fields as array: {fields: ['title', 'desc']}
Acceptance criteria
- Modify the
Fields<T>type to accept array(keyof MT)[] - Update code and test after the type change
- Document the new behavior in LB4/Working-with-data/fields-filter page
π Hacktoberfest 2020
Greetings π to all Hacktoberfest 2020 participants!
Here are few tips π to make your start easier, see also #6456:
- Before you start working on this issue, please leave a comment to let others know.
- If you are new to GitHub pull requests, then you can learn about the process in Submitting a pull request to LoopBack 4.
- If this is your first contribution to LoopBack, then please take a look at our Developer guide.
- Feel free to ask for help in
#loopback-contributorschannel, you can join our Slack workspace here.