-
Notifications
You must be signed in to change notification settings - Fork 363
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
Query on Included Model Properties #1042
Comments
The |
@zbarbuto I am trying to help you figure out what's the proper queries for your requirements, could you fork this repo https://github.com/strongloop/loopback-sandbox and replace with your code to reproduce your problem? The sample app with some sample data would be enough for debug. Thanks! |
Apologies haven't had a chance to get to the sandbox yet. Will be doing so tomorrow hopefully. |
I have setup a sandbox with the test case here: There is a boot script that seeds some random stores as well as customers for each store and purchases for some customers. Cheers |
@zbarbuto Thanks for the sandbox really appreciate it. If I understand correctly, the two cases you mentioned, one using BTW, we are using issue: strongloop/loopback#683 to keep track of applying filter on properties, part of JOIN feature, you can take a look if interested. I feel we'd better to create an issue for JOIN and then move and gather all related discussions there: |
Thanks for the prompt responses @jannyHou . I didn't find loopback 683 in my searching because I assumed it was a datasource juggler issue. It's a shame that this is still an issue given that that ticket was created two years ago as I know these types of queries come up all the time. Hopefully loopbackio/loopback-connector#42 can be merged soon.. Given you have created #1092 I am happy to move discussion there and close this issue. |
This is a follow-on from my comment in strongloop/loopback#517. It would be great if there was some way to perform queries on models through related model properties easily through the default query parameters.
The closest issues I could find were:
#94
#166
Consider the following models:
Store, Customer and Order.
Store hasMany Customers. Customer hasMany orders.
And consider I want to execute the following two queries:
There does not seem to be a way to do either of these without executing SQL directly via
ds.connector.execute
.Case 1 for example, you could use the following:
But this doesn't really do what I want because it will just return all stores and will have a series of dead paths that need to be pruned out manually. It would be great if we could add a flag to ONLY include the base model where the paths exist.
In case 2, I don't even believe this is possible through the default query methods.
Ideally, we could include a relation
as
something and then query on properties of that relation as is possible with SQL and arequired
property to flag that you only really care about models where the relation matching the query exists.Case 2 might look like
Case 1 might look like.
The text was updated successfully, but these errors were encountered: