1 | import { App } from "firebase-admin/app";
|
2 | import * as database from "firebase-admin/database";
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | interface IteratedDataSnapshot extends DataSnapshot {
|
8 | key: string;
|
9 | }
|
10 |
|
11 |
|
12 |
|
13 | export declare class DataSnapshot implements database.DataSnapshot {
|
14 | private app?;
|
15 | instance: string;
|
16 |
|
17 | private _ref;
|
18 |
|
19 | private _path;
|
20 |
|
21 | private _data;
|
22 |
|
23 | private _childPath;
|
24 | constructor(data: any, path?: string,
|
25 | app?: App, instance?: string);
|
26 | /**
|
27 | * Returns a [`Reference`](/docs/reference/admin/node/admin.database.Reference)
|
28 | * to the database location where the triggering write occurred. Has
|
29 | * full read and write access.
|
30 | */
|
31 | get ref(): database.Reference;
|
32 | /**
|
33 | * The key (last part of the path) of the location of this `DataSnapshot`.
|
34 | *
|
35 | * The last token in a database location is considered its key. For example,
|
36 | * "ada" is the key for the `/users/ada/` node. Accessing the key on any
|
37 | * `DataSnapshot` returns the key for the location that generated it.
|
38 | * However, accessing the key on the root URL of a database returns `null`.
|
39 | */
|
40 | get key(): string | null;
|
41 | /**
|
42 | * Extracts a JavaScript value from a `DataSnapshot`.
|
43 | *
|
44 | * Depending on the data in a `DataSnapshot`, the `val()` method may return a
|
45 | * scalar type (string, number, or boolean), an array, or an object. It may also
|
46 | * return `null`, indicating that the `DataSnapshot` is empty (contains no
|
47 | * data).
|
48 | *
|
49 | * @return The snapshot's contents as a JavaScript value (Object,
|
50 | * Array, string, number, boolean, or `null`).
|
51 | */
|
52 | val(): any;
|
53 | /**
|
54 | * Exports the entire contents of the `DataSnapshot` as a JavaScript object.
|
55 | *
|
56 | * @return The contents of the `DataSnapshot` as a JavaScript value
|
57 | * (Object, Array, string, number, boolean, or `null`).
|
58 | */
|
59 | exportVal(): any;
|
60 | /**
|
61 | * Gets the priority value of the data in this `DataSnapshot`.
|
62 | *
|
63 | * As an alternative to using priority, applications can order collections by
|
64 | * ordinary properties. See [Sorting and filtering
|
65 | * data](/docs/database/web/lists-of-data#sorting_and_filtering_data).
|
66 | *
|
67 | * @return The priority value of the data.
|
68 | */
|
69 | getPriority(): string | number | null;
|
70 | /**
|
71 | * Returns `true` if this `DataSnapshot` contains any data. It is slightly more
|
72 | * efficient than using `snapshot.val() !== null`.
|
73 | *
|
74 | * @return `true` if this `DataSnapshot` contains any data; otherwise, `false`.
|
75 | */
|
76 | exists(): boolean;
|
77 | /**
|
78 | * Gets a `DataSnapshot` for the location at the specified relative path.
|
79 | *
|
80 | * The relative path can either be a simple child name (for example, "ada") or
|
81 | * a deeper slash-separated path (for example, "ada/name/first").
|
82 | *
|
83 | * @param path A relative path from this location to the desired child
|
84 | * location.
|
85 | * @return The specified child location.
|
86 | */
|
87 | child(childPath: string): DataSnapshot;
|
88 | /**
|
89 | * Enumerates the `DataSnapshot`s of the children items.
|
90 | *
|
91 | * Because of the way JavaScript objects work, the ordering of data in the
|
92 | * JavaScript object returned by `val()` is not guaranteed to match the ordering
|
93 | * on the server nor the ordering of `child_added` events. That is where
|
94 | * `forEach()` comes in handy. It guarantees the children of a `DataSnapshot`
|
95 | * can be iterated in their query order.
|
96 | *
|
97 | * If no explicit `orderBy*()` method is used, results are returned
|
98 | * ordered by key (unless priorities are used, in which case, results are
|
99 | * returned by priority).
|
100 | *
|
101 | * @param action A function that is called for each child `DataSnapshot`.
|
102 | * The callback can return `true` to cancel further enumeration.
|
103 | *
|
104 | * @return `true` if enumeration was canceled due to your callback
|
105 | * returning `true`.
|
106 | */
|
107 | forEach(action: (a: IteratedDataSnapshot) => boolean | void): boolean;
|
108 | /**
|
109 | * Returns `true` if the specified child path has (non-`null`) data.
|
110 | *
|
111 | * @param path A relative path to the location of a potential child.
|
112 | * @return `true` if data exists at the specified child path; otherwise,
|
113 | * `false`.
|
114 | */
|
115 | hasChild(childPath: string): boolean;
|
116 | /**
|
117 | * Returns whether or not the `DataSnapshot` has any non-`null` child
|
118 | * properties.
|
119 | *
|
120 | * You can use `hasChildren()` to determine if a `DataSnapshot` has any
|
121 | * children. If it does, you can enumerate them using `forEach()`. If it
|
122 | * doesn't, then either this snapshot contains a primitive value (which can be
|
123 | * retrieved with `val()`) or it is empty (in which case, `val()` returns
|
124 | * `null`).
|
125 | *
|
126 | * @return `true` if this snapshot has any children; else `false`.
|
127 | */
|
128 | hasChildren(): boolean;
|
129 | /**
|
130 | * Returns the number of child properties of this `DataSnapshot`.
|
131 | *
|
132 | * @return Number of child properties of this `DataSnapshot`.
|
133 | */
|
134 | numChildren(): number;
|
135 | /**
|
136 | * Returns a JSON-serializable representation of this object.
|
137 | *
|
138 | * @return A JSON-serializable representation of this object.
|
139 | */
|
140 | toJSON(): Record<string, unknown>;
|
141 | /** Recursive function to check if keys are numeric & convert node object to array if they are
|
142 | *
|
143 | * @hidden
|
144 | */
|
145 | private _checkAndConvertToArray;
|
146 | /** @hidden */
|
147 | private _dup;
|
148 | /** @hidden */
|
149 | private _fullPath;
|
150 | }
|
151 | export {};
|