loopback icon indicating copy to clipboard operation
loopback copied to clipboard

Filter by properties of related models (use SQL JOIN in queries)

Open bluestaralone opened this issue 12 years ago • 53 comments

Ex: I have models Book and Category and i want to query Book with condition like below: Books with title contain "Art" and belongs to Category "Programming", please tell me how to do it ? I run this filter in Books model. GET /Books

{"include":{"categories"}, "where": {"title":{"like":"^Art"}, "categories.name":"Programming"}}

bluestaralone avatar Oct 23 '14 02:10 bluestaralone

See https://github.com/strongloop/loopback-datasource-juggler/issues/730 for a more detailed description of the requested feature.

bajtos avatar Jun 02 '16 11:06 bajtos

+1

princecharmx avatar Aug 02 '16 15:08 princecharmx

+1

AlexYegupov avatar Aug 16 '16 08:08 AlexYegupov

+1 please! \0/

reneolivo avatar Aug 24 '16 01:08 reneolivo

+1 please!

ericalves avatar Sep 03 '16 01:09 ericalves

This is definitely a "must have"!

shuckepco avatar Sep 27 '16 11:09 shuckepco

+1

pierissimo avatar Oct 13 '16 07:10 pierissimo

+1

bostondv avatar Oct 20 '16 17:10 bostondv

+1

rusackas avatar Oct 25 '16 18:10 rusackas

+1

Simone-cogno avatar Oct 27 '16 22:10 Simone-cogno

+1

jeff3yan avatar Oct 30 '16 22:10 jeff3yan

Please, don't spam everybody on this thread by posting +1 comments. Click on the "thumb up" icon at the top. It will also allow us to sort issues based on the number of upvotes.

bajtos avatar Nov 02 '16 21:11 bajtos

For those of us arriving to this issue late, where is the appropriate place to follow progress on this feature? It looks to me like it is indeed planned.

mull avatar Jan 18 '17 10:01 mull

+1 Can't believe this isn't included in the framework!

sneakersgames avatar Apr 18 '17 19:04 sneakersgames

Hi, I was just wondering if there is an ETA on this issue and if there is any suggested workaround other than using bidirectional relationships?

siyb avatar Apr 24 '17 09:04 siyb

I heard from @kjdelisle this feature is not possible unfortunately based on the currect architecture. @kjdelisle or @strongloop/sq-lb-apex could you please mention a brief note of the reasons why this feature is not possible and whether this will be available for LoopBack.Next for the people who are giving thumps up and waiting for this feature and then close it? Thanks!

CC: @bajtos

Amir-61 avatar Jul 20 '17 17:07 Amir-61

The problem is that this would require us to create a complete SQL ORM that handles multiple different SQL databases and their nuances, which has already been done in the form of things like Sequelize. Re-inventing this for our own DSL would be prohibitively complex given our current resources.

[email protected] will be easier to integrate into ORMs, frameworks, or libraries of all kinds.

Unfortunately, as a workaround for now, you'll have to build the queries yourself using the existing ParameterizedSQL functionality (to prevent SQL injection): https://apidocs.strongloop.com/loopback-connector/v/2.0.1/#using-loopback-connector

kjdelisle avatar Aug 14 '17 20:08 kjdelisle

I am starting a project in loopback .. this is major drawback if we can not make where conditions for related models . This is not a feature missing .. this is issue

vidhema avatar Aug 21 '17 16:08 vidhema

indeed, it`s very hard to write a non trivial application with good perfomance and clear code without this functionality. I think this should be seriously reconsidered if you plan to turn loopback in a robust framework for big applications.

vanderdill avatar Sep 14 '17 13:09 vanderdill