Firebase query orderByKey().limitToFirst(n).startAfter() returns n-1 items iso n
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 38/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- firebase, node.js, typescript
- 領域
- databases
調査の方向性
issue に示されている admin.database.Database.ref のクエリチェーンから始め、特に orderByKey()、limitToFirst()、startAfter() を確認します。提供されているページネーションループを使って、SDK 11.11.0 と 11.4.1 の違いを再現します。十分な数のキーが残っている場合に、lastDocument.key の後の 100 件を要求するクエリが 100 件を返し、リグレッションに対するカバレッジがあることを完了条件とします。
索引モデルが issue の本文から書いたものです。
説明
[READ] Step 1: Are you in the right place?
yes
[REQUIRED] Step 2: Describe your environment
- Operating System version: Ubuntu 22.04 lts
- Firebase SDK version: 11.11.0
- Firebase Product: realtime database (auth, database, storage, etc)
- Node.js version: 16.20.2
- NPM version: 8.19.4
[REQUIRED] Step 3: Describe the problem
Firebase query of type:
admin.database.Database.ref('collection').orderByKey().limitToFirst(100).startAfter(lastKey) only returns 99 items iso 100 even if more keys are in the firebase realtime database.
On version 11.4.1 of firebase-admin this query behaves as expected and 100 items are returned.
Steps to reproduce:
What happened? How can we make the problem occur?
This could be a description, log/console output, etc.
Relevant Code:
let query;
let lastDocument = null;
let lastBatchSize: number = 100;
while (lastBatchSize === 100) {
query = database.ref('collection').orderByKey()
.limitToFirst(100);
if (lastDocument !== null) {
query = query.startAfter(lastDocument.key);
}
const snapshot = await query.get();
const keys = Object.keys(snapshot.val() || {});
const docs = keys.map((key) => snapshot.child(key));
if (docs.length === 0) break;
console.log("docs length " + docs.length); //prints 99 on 11.11.0, prints 100 on 11.4.1
if (docs.length) {
lastDocument = docs[docs.length - 1];
}
lastBatchSize = docs.length;
}
- 主要言語
- TypeScript
- スター
- 1.7k
- フォーク
- 419
- 平均マージ
- 4日 20時間
- マージ済み PR(30日)
- 16
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
firebase/firebase-admin-node のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
firebase/firebase-admin-node#3234 ·
-
firebase/firebase-admin-node#3221 · コメント 3 件 · 担当者 1 名 ·
-
api: messaging
難易度 3/5 1〜2日 初心者へのやさしさ 70/100
firebase/firebase-admin-node#3215 ·
-
api: messaging
難易度 5/5 1週間以上 初心者へのやさしさ 28/100
firebase/firebase-admin-node#3214 ·
-
api: firestore type: feature request
firebase/firebase-admin-node#3183 · コメント 1 件 · 担当者 1 名 ·
firebase/firebase-admin-node の issue をすべて見る
似ている issue
-
bug(cli): hapi doctor inline-media prints a fabricated B:\ helper-script path in packaged installs オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
Crush オープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
catppuccin/catppuccin#3125 ·
-
Add a SECURITY.md オープン
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
ElementsProject/cln-application#167 · コメント 1 件 · リアクション 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
Quantco/pnpm-licenses#17 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100