Skip to content

Add IteratedDataSnapshot interface to match with firebase admin v12 #1517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 1, 2024
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