Querying related models make unnecessary requests
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
- #1801 von @regevbr — ohne Merge geschlossen
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 45/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- javascript
Rechercherichtung
Beginne mit dem Lesen von lib/scope.js, insbesondere des in dem verlinkten Commit und dem gemeldeten 2.x fork gezeigten Verhaltens. Reproduziere die hasMany-through query mit einem where filter und überprüfe, dass die through-model request nur zugehörige IDs zurückgibt, ohne vollständige related-model data abzurufen, während die abschließende related-model query den Filter weiterhin anwendet.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Steps to reproduce
Create a model called Book with the properties id,author,title
Add a hasMany relation between the default User model and the Book model using a through Model called UserToBook which has the following properties: userId,bookId
The relation is defined in the User model like so.
"books": {
"type": "hasMany",
"model": "Book",
"foreignKey": "userId",
"through": "UserToBook",
"keyThrough": "bookId"
},
Current Behavior
Querying the user for his books using a where filter performs 2 requests - one to the through model and one to the actual related model. The query to the through model is adding an include to the related model, which causes a fetch of a lot of data from the related model.
The reason this data is needed, is to extract the related model ids, so we can use it to filter out when performing the actual call the related model.
Expected Behavior
There is no need at all to fetch the related model data in the first call - we can simply get the ids from the through model, and use them
Link to reproduction sandbox
Working on it
Additional information
Since I'm using (sadly) loopback 2.x I have added the fix to my own fork - https://github.com/regevbr/loopback-datasource-juggler/blob/2.x/lib/scope.js
You can understand and base the fix based on the changes there
- Vorherrschende Sprache
- JavaScript
- Sterne
- 279
- Forks
- 362
- Ø Merge
- 21 Std. 14 Min.
- Gemergte PRs (30 T.)
- 16
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus loopbackio/loopback-datasource-juggler
-
Breaking changes for `loopback-datasource-juggler@7` not listed anywhereEvtl. wieder frei @dhmlau hat das vor 158 Tagen übernommen, und es ist kein Pull Request offen. Offenbug
loopbackio/loopback-datasource-juggler#2548 · 1 Kommentar · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Replace deprecated util._extend with Object.assign to ensure compatibility with modern Node.jsOffen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
loopbackio/loopback-datasource-juggler#2530 ·
Maintainer antworten meist innerhalb von 1 Tag
-
allow empty array in createAllEvtl. vergeben @ajay-prajapati07 hat das vor 533 Tagen übernommen. Offenfeature
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 45/100
loopbackio/loopback-datasource-juggler#2409 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 25/100
loopbackio/loopback-datasource-juggler#2319 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 55/100
loopbackio/loopback-datasource-juggler#1968 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in loopbackio/loopback-datasource-juggler
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
ipfs/ipfs-webui#2507 ·
-
Environments table lists page size 5 after 30Evtl. vergeben @raus7n hat das heute übernommen. Offen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
litmuschaos/litmus#5743 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 63/100
anothaDev/luci-theme-vantage#143 ·
Maintainer antworten meist innerhalb von 1 Tag
-
desktop grp:admin-donors type:graphics-bug ui-admin
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
kingcharleslzy-ai/dsh-purge#282 ·
Maintainer antworten meist innerhalb von 1 Tag