Querying related models make unnecessary requests
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
- #1801 @regevbr による — マージされずにクローズ
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- javascript
調査の方向性
まず lib/scope.js を読み、特にリンクされた commit と報告された 2.x fork に示されている動作を確認します。where filter を指定した hasMany-through query を再現し、through-model request が完全な related-model data を取得せずに関連する ID のみを返す一方で、最終的な related-model query には引き続きフィルターが適用されることを検証します。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- JavaScript
- スター
- 279
- フォーク
- 362
- 平均マージ
- 21時間 14分
- マージ済み PR(30日)
- 16
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
loopbackio/loopback-datasource-juggler のほかの issue
-
Breaking changes for `loopback-datasource-juggler@7` not listed anywhere再び着手できるかも @dhmlau が 158 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンbug
loopbackio/loopback-datasource-juggler#2548 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
loopbackio/loopback-datasource-juggler#2530 ·
メンテナーはふだん 1 日以内に返信
-
allow empty array in createAll対応中かも @ajay-prajapati07 が 533 日前に担当しました。 オープンfeature
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
loopbackio/loopback-datasource-juggler#2409 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
loopbackio/loopback-datasource-juggler#2319 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 55/100
loopbackio/loopback-datasource-juggler#1968 ·
メンテナーはふだん 1 日以内に返信
loopbackio/loopback-datasource-juggler の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
ipfs/ipfs-webui#2507 ·
-
Environments table lists page size 5 after 30対応中かも @raus7n が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
litmuschaos/litmus#5743 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 63/100
anothaDev/luci-theme-vantage#143 ·
メンテナーはふだん 1 日以内に返信
-
desktop grp:admin-donors type:graphics-bug ui-admin
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
kingcharleslzy-ai/dsh-purge#282 ·
メンテナーはふだん 1 日以内に返信