Count issue with related models using though model
I maintainer di solito rispondono entro 1 giorno
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
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 works as expected (there is a bug there as well which I will address in a different issue). The reason it works is the related function
https://github.com/strongloop/loopback-datasource-juggler/blob/d54d76947724d75a0f46b151c064742c678b0bbe/lib/scope.js#L61
Which, after querying the through model, also queries the related model directly.
When trying to count the number of books of a user, using a where filter (on the author for example), the result is the entire number of books the user has and not the number of books from that author. The reason for that is that the count function
https://github.com/strongloop/loopback-datasource-juggler/blob/d54d76947724d75a0f46b151c064742c678b0bbe/lib/scope.js#L509-L528
Only queries the though model, and not the related model directly.
Expected Behavior
Return the actual count, taking the filter under account
Link to reproduction sandbox
Working on it
Additional information
It seems that the findOne,updateAll and destroyAll suffer from the same issue
- Lingua principale
- JavaScript
- Stelle
- 279
- Fork
- 362
- Merge medio
- 21h 14m
- PR unite (30g)
- 16
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di loopbackio/loopback-datasource-juggler
-
Breaking changes for `loopback-datasource-juggler@7` not listed anywhereForse di nuovo libera @dhmlau l’ha presa 158 giorni fa e non c’è nessuna pull request aperta. Apertabug
loopbackio/loopback-datasource-juggler#2548 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Replace deprecated util._extend with Object.assign to ensure compatibility with modern Node.jsAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
loopbackio/loopback-datasource-juggler#2530 ·
I maintainer di solito rispondono entro 1 giorno
-
allow empty array in createAllForse già presa @ajay-prajapati07 l’ha presa 533 giorni fa. Apertafeature
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
loopbackio/loopback-datasource-juggler#2409 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
loopbackio/loopback-datasource-juggler#2319 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 55/100
loopbackio/loopback-datasource-juggler#1968 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di loopbackio/loopback-datasource-juggler
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
anothaDev/luci-theme-vantage#143 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
kingcharleslzy-ai/dsh-purge#282 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
-
a-corriger bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
christian-raj/S-Aloha#340 ·
-
area:image documentation good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno