Skip to content

Commit 9bda8f7

Browse files
authoredFeb 1, 2024··
Add IteratedDataSnapshot interface to match with firebase admin v12 (#1517)
* add IteratedDataSnapshot interface to match with firebase admin v12 * rebase upstream
1 parent e6f5d89 commit 9bda8f7

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed
 

‎CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
- Fixes access on deeply nested, nonexistent property. (#1432)
2+
- Add IteratedDataSnapshot interface to match with firebase admin v12 (#1517).

‎src/common/providers/database.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ import * as database from "firebase-admin/database";
2525
import { firebaseConfig } from "../../common/config";
2626
import { joinPath, pathParts } from "../../common/utilities/path";
2727

28+
/**
29+
* Pulled from @firebase/database-types, make sure the interface is updated on dependencies upgrades.
30+
* Represents a child snapshot of a `Reference` that is being iterated over. The key will never be undefined.
31+
*/
32+
interface IteratedDataSnapshot extends DataSnapshot {
33+
key: string; // key of the location of this snapshot.
34+
}
35+
2836
/**
2937
* Interface representing a Firebase Realtime database data snapshot.
3038
*/
@@ -207,7 +215,7 @@ export class DataSnapshot implements database.DataSnapshot {
207215
* @return `true` if enumeration was canceled due to your callback
208216
* returning `true`.
209217
*/
210-
forEach(action: (a: DataSnapshot) => boolean | void): boolean {
218+
forEach(action: (a: IteratedDataSnapshot) => boolean | void): boolean {
211219
const val = this.val() || {};
212220
if (typeof val === "object") {
213221
return Object.keys(val).some((key) => action(this.child(key)) === true);

0 commit comments

Comments
 (0)
Please sign in to comment.