Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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