-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Filter by properties of related models (use SQL JOIN in queries) #683
Comments
See loopbackio/loopback-datasource-juggler#730 for a more detailed description of the requested feature. |
+1 |
1 similar comment
+1 |
+1 please! \0/ |
+1 please! |
This is definitely a "must have"! |
+1 |
+1 |
3 similar comments
+1 |
+1 |
+1 |
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. |
Boy, its broken at the core just as many "open source" framework, which itself is an illusion. These guys are obviously building apps for clients and not for community. We are good to be testers, pull requesters, fixers, but left fairly behind if it comes to an issue that is not in the interest of loopback main clients. |
+1 |
Is this going to be implemented on lb4 ? |
@barocsi well a lot of time the trigger to build huge open source libs is: some company needs and build a framework and then is released publicly eg Angular React .... So as @cantoute is saying this situation is absolutely unreal. I'd like to mention @bajtos as maintainer to ask him if there are some updates on this topic |
I don't have any update to share. Our focus is on delivering LoopBack 4.0 GA, we don't have bandwidth to work on this feature until 4.0 is released. |
@bajtos Sorry to bother you, but since the Loopback 4.0 is released is there anything planed for this feature? Thanks! |
I can't believe that Loopback doesn't support this basic feature. Does Loopback 4.0 support it? |
Hi,
Seams that the best way is to cast you vote here
loopbackio/loopback-next#512
Left and Inner Joins on queries. Perhaps just use GraphQL with something like Join Monster <https://github.com/stems/join-monster> to generate smart SQL behind the scenes.
this feature doesn't seem to be demanded... while to me it seams like an essential and basic need for database driven apps...
… Le 1 nov. 2018 à 06:14, Nguyen Hoang ***@***.***> a écrit :
I can't believe that Loopback doesn't support this basic feature. Does Loopback 4.0 support it?
To resolve this problem, I have to use native sql.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#683 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AD42peEIKFFTLhlIivQdRbUAbxJt3jpoks5uqrtcgaJpZM4Cx_lQ>.
|
This is not resolved yet? Thanks |
if this is not resolved: Why in the docu are this ? https://loopback.io/doc/en/lb3/Include-filter.html Thanks |
@pookdeveloper IIUC, the condition specified in What does not work:
What may work using
I hope my example is making the difference clear. |
Is Loopback 4 supporting this now? |
Is there any update on this? |
This is completely insane. |
I can do that with typeorm https://typeorm.io/#/ |
@pookdeveloper You mean that you use |
I use combined |
@pookdeveloper Thank you, is somewhere a tutorial on how we can setup this solution? It seems that this can solve many problems that loopback has not addressed yet. |
I will try today to do a tutorial |
@pookdeveloper could you please give us an example? thanks very much! |
It's not hard to just override the _buildWhere method at boot time. const set = require('lodash/set');
module.exports = function (app) {
const connector = app.dataSources.db.connector;
const _buildWhere = connector._buildWhere.bind(connector);
connector._buildWhere = function (model, where) {
for (var key in where) {
if (key.includes('.')) {
Object.assign(where, set({}, key, where[key]));
delete where[key];
}
}
let whereClause = _buildWhere(model, where);
const relations = app.models[model].relations;
for (const key in where) {
if (relations && relations[key]) {
const relation = relations[key];
const inSelect = this.buildSelect(relation.modelTo.modelName, {
fields: [relation.keyTo],
where: {
and: [
app.models[model]._coerce(where[key], {}, app.models[relation.modelTo.modelName].definition)
]
}
}, {parameterize: false, order: false});
whereClause = new ParameterizedSQL({
sql: whereClause.sql + (whereClause.sql !== '' ? ' AND ' : '') + this.columnEscaped(relation.modelFrom.modelName, relation.keyFrom) + ' IN (' + inSelect.sql + ')',
params: whereClause.params.concat(inSelect.params),
});
}
}
return whereClause;
}
} And then {"include":{"categories"}, "where": {"title":{"like":"^Art"}, "categories.name":"Programming"}} or just {"where": {"categories.name":"Programming"}} or even {"where": {"models1.models2.models3.field":"someValue"}}
{"where":{"models1":{"and":[{"someField1":"someValue1"},{"someField2":"someValue2"}]}}}
|
How to use it in loopback4? |
where does |
const ParameterizedSQL = require('loopback-connector/lib/parameterized-sql'); |
Or perhaps the way to go is switch to typeORM .... But at this time support for it in lb is at useless... nestjs ? |
8 years and counting. Still, this basic feature is not there. If I would have known earlier about this, I would have not chosen LB4 |
I switched to nestjs + typeorm and no regrets |
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
The text was updated successfully, but these errors were encountered: