Firebase query orderByKey().limitToFirst(n).startAfter() returns n-1 items iso n
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 38/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- firebase, node.js, typescript
- Lĩnh vực
- databases
Hướng nghiên cứu
Inizia con la catena di query admin.database.Database.ref mostrata nell’issue, in particolare orderByKey(), limitToFirst() e startAfter(). Riproduci la differenza tra SDK 11.11.0 e 11.4.1 usando il ciclo di paginazione fornito. Il lavoro è completo quando una query che richiede 100 elementi dopo lastDocument.key restituisce 100 finché rimangono chiavi sufficienti, con una copertura per la regressione.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
[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;
}
- Ngôn ngữ chính
- TypeScript
- Star
- 1.7k
- Fork
- 419
- Merge trung bình
- 4 ngày 20 giờ
- Pull request đã merge (30 ngày)
- 16
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của firebase/firebase-admin-node
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
firebase/firebase-admin-node#3234 ·
-
firebase/firebase-admin-node#3221 · 3 bình luận · 1 người được giao ·
-
api: messaging
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 70/100
firebase/firebase-admin-node#3215 ·
-
api: messaging
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 28/100
firebase/firebase-admin-node#3214 ·
-
api: firestore type: feature request
firebase/firebase-admin-node#3183 · 1 bình luận · 1 người được giao ·
Tất cả issue của firebase/firebase-admin-node
Issue tương tự
-
bug(cli): hapi doctor inline-media prints a fabricated B:\ helper-script path in packaged installs Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Crush Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
catppuccin/catppuccin#3125 ·
-
Add a SECURITY.md Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
ElementsProject/cln-application#167 · 1 bình luận · 1 reaction ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Quantco/pnpm-licenses#17 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100