I have a page property, that needs to filter the items being worked on, but the filter needed doesn’t fit a simple where clause.
Specifically, I want to find a set of Roles (not the primary data being edited on the page), but those roles need to be ones that have a specific product associated to them.
Is it right that I need to therefore have a method that sets up the needed filter clause, executes a Find query against the Role object, then assign the results to the property for use on the page?
I am not sure I have a clear picture of the use case but here are a couple of pointers that may help.
You can only do “left joins” with filters and includes in LoopBack. Sometimes you can simulate a full join by doing two queries. I am not sure I followed you example completely but something like this may work:
- Read the product (s) and include the roles
- Extract the role ids from the list of product(s).roles
- Add a where clause in your items: {where: {roleId: {inq: roleIds}}}