Skip to content

Commit

Permalink
Add IteratedDataSnapshot interface to match with firebase admin v12 (#…
Browse files Browse the repository at this point in the history
…1517)

* add IteratedDataSnapshot interface to match with firebase admin v12

* rebase upstream
  • Loading branch information
colerogers authored Feb 1, 2024
1 parent e6f5d89 commit 9bda8f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Fixes access on deeply nested, nonexistent property. (#1432)
- Add IteratedDataSnapshot interface to match with firebase admin v12 (#1517).
10 changes: 9 additions & 1 deletion src/common/providers/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ import * as database from "firebase-admin/database";
import { firebaseConfig } from "../../common/config";
import { joinPath, pathParts } from "../../common/utilities/path";

/**
* Pulled from @firebase/database-types, make sure the interface is updated on dependencies upgrades.
* Represents a child snapshot of a `Reference` that is being iterated over. The key will never be undefined.
*/
interface IteratedDataSnapshot extends DataSnapshot {
key: string; // key of the location of this snapshot.
}

/**
* Interface representing a Firebase Realtime database data snapshot.
*/
Expand Down Expand Up @@ -207,7 +215,7 @@ export class DataSnapshot implements database.DataSnapshot {
* @return `true` if enumeration was canceled due to your callback
* returning `true`.
*/
forEach(action: (a: DataSnapshot) => boolean | void): boolean {
forEach(action: (a: IteratedDataSnapshot) => boolean | void): boolean {
const val = this.val() || {};
if (typeof val === "object") {
return Object.keys(val).some((key) => action(this.child(key)) === true);
Expand Down

0 comments on commit 9bda8f7

Please sign in to comment.