@react-native-firebase/database 18.4.0 → 18.5.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +6 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/modular/index.d.ts +217 -0
- package/lib/modular/index.js +124 -0
- package/lib/modular/query.d.ts +1025 -0
- package/lib/modular/query.js +291 -0
- package/lib/modular/transaction.d.ts +56 -0
- package/lib/modular/transaction.js +15 -0
- package/lib/version.js +1 -1
- package/package.json +3 -3
@@ -0,0 +1,1025 @@
|
|
1
|
+
import { FirebaseDatabaseTypes } from '../..';
|
2
|
+
|
3
|
+
import Query = FirebaseDatabaseTypes.Query;
|
4
|
+
import DataSnapshot = FirebaseDatabaseTypes.DataSnapshot;
|
5
|
+
import DatabaseReference = FirebaseDatabaseTypes.Reference;
|
6
|
+
import OnDisconnect = FirebaseDatabaseTypes.OnDisconnect;
|
7
|
+
|
8
|
+
export type Query = Query;
|
9
|
+
export type DataSnapshot = DataSnapshot;
|
10
|
+
export type DatabaseReference = DatabaseReference;
|
11
|
+
export type OnDisconnect = OnDisconnect;
|
12
|
+
|
13
|
+
/**
|
14
|
+
* A `Promise` that can also act as a `DatabaseReference` when returned by
|
15
|
+
* {@link push}. The reference is available immediately and the `Promise` resolves
|
16
|
+
* as the write to the backend completes.
|
17
|
+
*/
|
18
|
+
export interface ThenableReference
|
19
|
+
extends DatabaseReference,
|
20
|
+
Pick<Promise<DatabaseReference>, 'then' | 'catch'> {}
|
21
|
+
|
22
|
+
export type Unsubscribe = () => void;
|
23
|
+
|
24
|
+
export interface ListenOptions {
|
25
|
+
readonly onlyOnce?: boolean;
|
26
|
+
}
|
27
|
+
|
28
|
+
/** Describes the different query constraints available in this SDK. */
|
29
|
+
export type QueryConstraintType =
|
30
|
+
| 'endAt'
|
31
|
+
| 'endBefore'
|
32
|
+
| 'startAt'
|
33
|
+
| 'startAfter'
|
34
|
+
| 'limitToFirst'
|
35
|
+
| 'limitToLast'
|
36
|
+
| 'orderByChild'
|
37
|
+
| 'orderByKey'
|
38
|
+
| 'orderByPriority'
|
39
|
+
| 'orderByValue'
|
40
|
+
| 'equalTo';
|
41
|
+
|
42
|
+
/**
|
43
|
+
* A `QueryConstraint` is used to narrow the set of documents returned by a
|
44
|
+
* Database query. `QueryConstraint`s are created by invoking {@link endAt},
|
45
|
+
* {@link endBefore}, {@link startAt}, {@link startAfter}, {@link
|
46
|
+
* limitToFirst}, {@link limitToLast}, {@link orderByChild},
|
47
|
+
* {@link orderByChild}, {@link orderByKey} , {@link orderByPriority} ,
|
48
|
+
* {@link orderByValue} or {@link equalTo} and
|
49
|
+
* can then be passed to {@link query} to create a new query instance that
|
50
|
+
* also contains this `QueryConstraint`.
|
51
|
+
*/
|
52
|
+
export interface QueryConstraint {
|
53
|
+
/** The type of this query constraints */
|
54
|
+
readonly _type: QueryConstraintType;
|
55
|
+
|
56
|
+
_apply(query: Query): Query;
|
57
|
+
}
|
58
|
+
|
59
|
+
/**
|
60
|
+
* Creates a `QueryConstraint` with the specified ending point.
|
61
|
+
*
|
62
|
+
* Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
|
63
|
+
* allows you to choose arbitrary starting and ending points for your queries.
|
64
|
+
*
|
65
|
+
* The ending point is inclusive, so children with exactly the specified value
|
66
|
+
* will be included in the query. The optional key argument can be used to
|
67
|
+
* further limit the range of the query. If it is specified, then children that
|
68
|
+
* have exactly the specified value must also have a key name less than or equal
|
69
|
+
* to the specified key.
|
70
|
+
*
|
71
|
+
* @param value - The value to end at. The argument type depends on which
|
72
|
+
* `orderBy*()` function was used in this query. Specify a value that matches
|
73
|
+
* the `orderBy*()` type. When used in combination with `orderByKey()`, the
|
74
|
+
* value must be a string.
|
75
|
+
* @param key - The child key to end at, among the children with the previously
|
76
|
+
* specified priority. This argument is only allowed if ordering by child,
|
77
|
+
* value, or priority.
|
78
|
+
*/
|
79
|
+
export declare function endAt(
|
80
|
+
value: number | string | boolean | null,
|
81
|
+
key?: string,
|
82
|
+
): QueryConstraint;
|
83
|
+
|
84
|
+
/**
|
85
|
+
* Creates a QueryConstraint with the specified ending point (exclusive).
|
86
|
+
*
|
87
|
+
* Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()` allows you to
|
88
|
+
* choose arbitrary starting and ending points for your queries.
|
89
|
+
*
|
90
|
+
* The ending point is exclusive. If only a value is provided, children with a
|
91
|
+
* value less than the specified value will be included in the query. If a key
|
92
|
+
* is specified, then children must have a value less than or equal to the
|
93
|
+
* specified value and a key name less than the specified key.
|
94
|
+
*
|
95
|
+
* @param value - The value to end before. The argument type depends on which
|
96
|
+
* `orderBy*()` function was used in this query. Specify a value that matches
|
97
|
+
* the `orderBy*()` type. When used in combination with `orderByKey()`, the
|
98
|
+
* value must be a string.
|
99
|
+
* @param key - The child key to end before, among the children with the
|
100
|
+
* previously specified priority. This argument is only allowed if ordering by
|
101
|
+
* child, value, or priority.
|
102
|
+
*/
|
103
|
+
export declare function endBefore(
|
104
|
+
value: number | string | boolean | null,
|
105
|
+
key?: string,
|
106
|
+
): QueryConstraint;
|
107
|
+
|
108
|
+
/**
|
109
|
+
* Creates a QueryConstraint that includes children that match the specified value.
|
110
|
+
*
|
111
|
+
* Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()` allows
|
112
|
+
* you to choose arbitrary starting and ending points for your queries.
|
113
|
+
*
|
114
|
+
* The optional key argument can be used to further limit the range of the
|
115
|
+
* query. If it is specified, then children that have exactly the specified
|
116
|
+
* value must also have exactly the specified key as their key name. This
|
117
|
+
* can be used to filter result sets with many matches for the same value.
|
118
|
+
*
|
119
|
+
* @param value - The value to match for. The argument type depends on which
|
120
|
+
* `orderBy*()` function was used in this query. Specify a value that matches
|
121
|
+
* the `orderBy*()` type. When used in combination with `orderByKey()`, the
|
122
|
+
* value must be a string.
|
123
|
+
* @param key - The child key to start at, among the children with the
|
124
|
+
* previously specified priority. This argument is only allowed if ordering by
|
125
|
+
* child, value, or priority.
|
126
|
+
*/
|
127
|
+
export declare function equalTo(
|
128
|
+
value: number | string | boolean | null,
|
129
|
+
key?: string,
|
130
|
+
): QueryConstraint;
|
131
|
+
|
132
|
+
/**
|
133
|
+
* Creates a `QueryConstraint` that includes children that match the specified
|
134
|
+
* value.
|
135
|
+
*
|
136
|
+
* Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
|
137
|
+
* allows you to choose arbitrary starting and ending points for your queries.
|
138
|
+
*
|
139
|
+
* The optional key argument can be used to further limit the range of the
|
140
|
+
* query. If it is specified, then children that have exactly the specified
|
141
|
+
* value must also have exactly the specified key as their key name. This can be
|
142
|
+
* used to filter result sets with many matches for the same value.
|
143
|
+
*
|
144
|
+
* @param value - The value to match for. The argument type depends on which
|
145
|
+
* `orderBy*()` function was used in this query. Specify a value that matches
|
146
|
+
* the `orderBy*()` type. When used in combination with `orderByKey()`, the
|
147
|
+
* value must be a string.
|
148
|
+
* @param key - The child key to start at, among the children with the
|
149
|
+
* previously specified priority. This argument is only allowed if ordering by
|
150
|
+
* child, value, or priority.
|
151
|
+
*/
|
152
|
+
export function equalTo(value: number | string | boolean | null, key?: string): QueryConstraint;
|
153
|
+
|
154
|
+
/**
|
155
|
+
* Creates a QueryConstraint with the specified starting point.
|
156
|
+
*
|
157
|
+
* Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
|
158
|
+
* allows you to choose arbitrary starting and ending points for your queries.
|
159
|
+
*
|
160
|
+
* The starting point is inclusive, so children with exactly the specified
|
161
|
+
* value will be included in the query. The optional key argument can be used
|
162
|
+
* to further limit the range of the query. If it is specified, then children
|
163
|
+
* that have exactly the specified value must also have a key name greater than
|
164
|
+
* or equal to the specified key.
|
165
|
+
*
|
166
|
+
* @param value - The value to start at. The argument type depends on which
|
167
|
+
* `orderBy*()` function was used in this query. Specify a value that matches
|
168
|
+
* the `orderBy*()` type. When used in combination with `orderByKey()`, the
|
169
|
+
* value must be a string.
|
170
|
+
* @param key - The child key to start at. This argument is only allowed if
|
171
|
+
* ordering by child, value, or priority.
|
172
|
+
*/
|
173
|
+
export declare function startAt(
|
174
|
+
value?: number | string | boolean | null,
|
175
|
+
key?: string,
|
176
|
+
): QueryConstraint;
|
177
|
+
|
178
|
+
/**
|
179
|
+
* Creates a `QueryConstraint` with the specified starting point.
|
180
|
+
*
|
181
|
+
* Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
|
182
|
+
* allows you to choose arbitrary starting and ending points for your queries.
|
183
|
+
*
|
184
|
+
* The starting point is inclusive, so children with exactly the specified value
|
185
|
+
* will be included in the query. The optional key argument can be used to
|
186
|
+
* further limit the range of the query. If it is specified, then children that
|
187
|
+
* have exactly the specified value must also have a key name greater than or
|
188
|
+
* equal to the specified key.
|
189
|
+
*
|
190
|
+
* @param value - The value to start at. The argument type depends on which
|
191
|
+
* `orderBy*()` function was used in this query. Specify a value that matches
|
192
|
+
* the `orderBy*()` type. When used in combination with `orderByKey()`, the
|
193
|
+
* value must be a string.
|
194
|
+
* @param key - The child key to start at. This argument is only allowed if
|
195
|
+
* ordering by child, value, or priority.
|
196
|
+
*/
|
197
|
+
export function startAt(
|
198
|
+
value: number | string | boolean | null = null,
|
199
|
+
key?: string,
|
200
|
+
): QueryConstraint;
|
201
|
+
|
202
|
+
/**
|
203
|
+
* Creates a `QueryConstraint` with the specified starting point (exclusive).
|
204
|
+
*
|
205
|
+
* Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
|
206
|
+
* allows you to choose arbitrary starting and ending points for your queries.
|
207
|
+
*
|
208
|
+
* The starting point is exclusive. If only a value is provided, children
|
209
|
+
* with a value greater than the specified value will be included in the query.
|
210
|
+
* If a key is specified, then children must have a value greater than or equal
|
211
|
+
* to the specified value and a a key name greater than the specified key.
|
212
|
+
*
|
213
|
+
* @param value - The value to start after. The argument type depends on which
|
214
|
+
* `orderBy*()` function was used in this query. Specify a value that matches
|
215
|
+
* the `orderBy*()` type. When used in combination with `orderByKey()`, the
|
216
|
+
* value must be a string.
|
217
|
+
* @param key - The child key to start after. This argument is only allowed if
|
218
|
+
* ordering by child, value, or priority.
|
219
|
+
*/
|
220
|
+
export function startAfter(value: number | string | boolean | null, key?: string): QueryConstraint;
|
221
|
+
|
222
|
+
/**
|
223
|
+
* Creates a `QueryConstraint` with the specified starting point (exclusive).
|
224
|
+
*
|
225
|
+
* Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
|
226
|
+
* allows you to choose arbitrary starting and ending points for your queries.
|
227
|
+
*
|
228
|
+
* The starting point is exclusive. If only a value is provided, children
|
229
|
+
* with a value greater than the specified value will be included in the query.
|
230
|
+
* If a key is specified, then children must have a value greater than or equal
|
231
|
+
* to the specified value and a key name greater than the specified key.
|
232
|
+
*
|
233
|
+
* @param value - The value to start after. The argument type depends on which
|
234
|
+
* `orderBy*()` function was used in this query. Specify a value that matches
|
235
|
+
* the `orderBy*()` type. When used in combination with `orderByKey()`, the
|
236
|
+
* value must be a string.
|
237
|
+
* @param key - The child key to start after. This argument is only allowed if
|
238
|
+
* ordering by child, value, or priority.
|
239
|
+
*/
|
240
|
+
export function startAfter(value: number | string | boolean | null, key?: string): QueryConstraint;
|
241
|
+
|
242
|
+
/**
|
243
|
+
* Creates a new `QueryConstraint` that if limited to the first specific number
|
244
|
+
* of children.
|
245
|
+
*
|
246
|
+
* The `limitToFirst()` method is used to set a maximum number of children to be
|
247
|
+
* synced for a given callback. If we set a limit of 100, we will initially only
|
248
|
+
* receive up to 100 `child_added` events. If we have fewer than 100 messages
|
249
|
+
* stored in our Database, a `child_added` event will fire for each message.
|
250
|
+
* However, if we have over 100 messages, we will only receive a `child_added`
|
251
|
+
* event for the first 100 ordered messages. As items change, we will receive
|
252
|
+
* `child_removed` events for each item that drops out of the active list so
|
253
|
+
* that the total number stays at 100.
|
254
|
+
*
|
255
|
+
* @param limit - The maximum number of nodes to include in this query.
|
256
|
+
*/
|
257
|
+
export function limitToFirst(limit: number): QueryConstraint;
|
258
|
+
|
259
|
+
/**
|
260
|
+
* Creates a new `QueryConstraint` that is limited to return only the last
|
261
|
+
* specified number of children.
|
262
|
+
*
|
263
|
+
* The `limitToLast()` method is used to set a maximum number of children to be
|
264
|
+
* synced for a given callback. If we set a limit of 100, we will initially only
|
265
|
+
* receive up to 100 `child_added` events. If we have fewer than 100 messages
|
266
|
+
* stored in our Database, a `child_added` event will fire for each message.
|
267
|
+
* However, if we have over 100 messages, we will only receive a `child_added`
|
268
|
+
* event for the last 100 ordered messages. As items change, we will receive
|
269
|
+
* `child_removed` events for each item that drops out of the active list so
|
270
|
+
* that the total number stays at 100.
|
271
|
+
*
|
272
|
+
* @param limit - The maximum number of nodes to include in this query.
|
273
|
+
*/
|
274
|
+
export function limitToLast(limit: number): QueryConstraint;
|
275
|
+
|
276
|
+
/**
|
277
|
+
* Creates a new `QueryConstraint` that orders by the specified child key.
|
278
|
+
*
|
279
|
+
* Queries can only order by one key at a time. Calling `orderByChild()`
|
280
|
+
* multiple times on the same query is an error.
|
281
|
+
*
|
282
|
+
* Firebase queries allow you to order your data by any child key on the fly.
|
283
|
+
* However, if you know in advance what your indexes will be, you can define
|
284
|
+
* them via the .indexOn rule in your Security Rules for better performance.
|
285
|
+
*
|
286
|
+
* @param path - The path to order by.
|
287
|
+
*/
|
288
|
+
export function orderByChild(path: string): QueryConstraint;
|
289
|
+
|
290
|
+
/**
|
291
|
+
* Creates a new `QueryConstraint` that orders by the key.
|
292
|
+
*
|
293
|
+
* Sorts the results of a query by their (ascending) key values.
|
294
|
+
*/
|
295
|
+
export function orderByKey(): QueryConstraint;
|
296
|
+
|
297
|
+
/**
|
298
|
+
* Creates a new `QueryConstraint` that orders by priority.
|
299
|
+
*
|
300
|
+
* Applications need not use priority but can order collections by
|
301
|
+
* ordinary properties
|
302
|
+
*/
|
303
|
+
export function orderByPriority(): QueryConstraint;
|
304
|
+
|
305
|
+
/**
|
306
|
+
* Creates a new `QueryConstraint` that orders by value.
|
307
|
+
*
|
308
|
+
* If the children of a query are all scalar values (string, number, or
|
309
|
+
* boolean), you can order the results by their (ascending) values.
|
310
|
+
*/
|
311
|
+
export function orderByValue(): QueryConstraint;
|
312
|
+
|
313
|
+
/**
|
314
|
+
* Creates a new immutable instance of `Query` that is extended to also include
|
315
|
+
* additional query constraints.
|
316
|
+
*
|
317
|
+
* @param query - The Query instance to use as a base for the new constraints.
|
318
|
+
* @param queryConstraints - The list of `QueryConstraint`s to apply.
|
319
|
+
* @throws if any of the provided query constraints cannot be combined with the
|
320
|
+
* existing or new constraints.
|
321
|
+
*/
|
322
|
+
export function query(query: Query, ...queryConstraints: QueryConstraint[]): Query;
|
323
|
+
|
324
|
+
/**
|
325
|
+
* Listens for data changes at a particular location.
|
326
|
+
*
|
327
|
+
* This is the primary way to read data from a Database. Your callback
|
328
|
+
* will be triggered for the initial data and again whenever the data changes.
|
329
|
+
* Invoke the returned unsubscribe callback to stop receiving updates.
|
330
|
+
*
|
331
|
+
* An `onValue` event will trigger once with the initial data stored at this
|
332
|
+
* location, and then trigger again each time the data changes. The
|
333
|
+
* `DataSnapshot` passed to the callback will be for the location at which
|
334
|
+
* `on()` was called. It won't trigger until the entire contents has been
|
335
|
+
* synchronized. If the location has no data, it will be triggered with an empty
|
336
|
+
* `DataSnapshot` (`val()` will return `null`).
|
337
|
+
*
|
338
|
+
* @param query - The query to run.
|
339
|
+
* @param callback - A callback that fires when the specified event occurs. The
|
340
|
+
* callback will be passed a DataSnapshot.
|
341
|
+
* @param cancelCallback - An optional callback that will be notified if your
|
342
|
+
* event subscription is ever canceled because your client does not have
|
343
|
+
* permission to read this data (or it had permission but has now lost it).
|
344
|
+
* This callback will be passed an `Error` object indicating why the failure
|
345
|
+
* occurred.
|
346
|
+
* @returns A function that can be invoked to remove the listener.
|
347
|
+
*/
|
348
|
+
export function onValue(
|
349
|
+
query: Query,
|
350
|
+
callback: (snapshot: DataSnapshot) => unknown,
|
351
|
+
cancelCallback?: (error: Error) => unknown,
|
352
|
+
): Unsubscribe;
|
353
|
+
|
354
|
+
/**
|
355
|
+
* Listens for data changes at a particular location.
|
356
|
+
*
|
357
|
+
* This is the primary way to read data from a Database. Your callback
|
358
|
+
* will be triggered for the initial data and again whenever the data changes.
|
359
|
+
* Invoke the returned unsubscribe callback to stop receiving updates.
|
360
|
+
*
|
361
|
+
* An `onValue` event will trigger once with the initial data stored at this
|
362
|
+
* location, and then trigger again each time the data changes. The
|
363
|
+
* `DataSnapshot` passed to the callback will be for the location at which
|
364
|
+
* `on()` was called. It won't trigger until the entire contents has been
|
365
|
+
* synchronized. If the location has no data, it will be triggered with an empty
|
366
|
+
* `DataSnapshot` (`val()` will return `null`).
|
367
|
+
*
|
368
|
+
* @param query - The query to run.
|
369
|
+
* @param callback - A callback that fires when the specified event occurs. The
|
370
|
+
* callback will be passed a DataSnapshot.
|
371
|
+
* @param options - An object that can be used to configure `onlyOnce`, which
|
372
|
+
* then removes the listener after its first invocation.
|
373
|
+
* @returns A function that can be invoked to remove the listener.
|
374
|
+
*/
|
375
|
+
export function onValue(
|
376
|
+
query: Query,
|
377
|
+
callback: (snapshot: DataSnapshot) => unknown,
|
378
|
+
options: ListenOptions,
|
379
|
+
): Unsubscribe;
|
380
|
+
|
381
|
+
/**
|
382
|
+
* Listens for data changes at a particular location.
|
383
|
+
*
|
384
|
+
* This is the primary way to read data from a Database. Your callback
|
385
|
+
* will be triggered for the initial data and again whenever the data changes.
|
386
|
+
* Invoke the returned unsubscribe callback to stop receiving updates.
|
387
|
+
*
|
388
|
+
* An `onValue` event will trigger once with the initial data stored at this
|
389
|
+
* location, and then trigger again each time the data changes. The
|
390
|
+
* `DataSnapshot` passed to the callback will be for the location at which
|
391
|
+
* `on()` was called. It won't trigger until the entire contents has been
|
392
|
+
* synchronized. If the location has no data, it will be triggered with an empty
|
393
|
+
* `DataSnapshot` (`val()` will return `null`).
|
394
|
+
*
|
395
|
+
* @param query - The query to run.
|
396
|
+
* @param callback - A callback that fires when the specified event occurs. The
|
397
|
+
* callback will be passed a DataSnapshot.
|
398
|
+
* @param cancelCallback - An optional callback that will be notified if your
|
399
|
+
* event subscription is ever canceled because your client does not have
|
400
|
+
* permission to read this data (or it had permission but has now lost it).
|
401
|
+
* This callback will be passed an `Error` object indicating why the failure
|
402
|
+
* occurred.
|
403
|
+
* @param options - An object that can be used to configure `onlyOnce`, which
|
404
|
+
* then removes the listener after its first invocation.
|
405
|
+
* @returns A function that can be invoked to remove the listener.
|
406
|
+
*/
|
407
|
+
export function onValue(
|
408
|
+
query: Query,
|
409
|
+
callback: (snapshot: DataSnapshot) => unknown,
|
410
|
+
cancelCallback: (error: Error) => unknown,
|
411
|
+
options: ListenOptions,
|
412
|
+
): Unsubscribe;
|
413
|
+
|
414
|
+
export function onValue(
|
415
|
+
query: Query,
|
416
|
+
callback: (snapshot: DataSnapshot) => unknown,
|
417
|
+
cancelCallbackOrListenOptions?: ((error: Error) => unknown) | ListenOptions,
|
418
|
+
options?: ListenOptions,
|
419
|
+
): Unsubscribe;
|
420
|
+
|
421
|
+
/**
|
422
|
+
* Listens for data changes at a particular location.
|
423
|
+
*
|
424
|
+
* This is the primary way to read data from a Database. Your callback
|
425
|
+
* will be triggered for the initial data and again whenever the data changes.
|
426
|
+
* Invoke the returned unsubscribe callback to stop receiving updates.
|
427
|
+
*
|
428
|
+
* An `onChildAdded` event will be triggered once for each initial child at this
|
429
|
+
* location, and it will be triggered again every time a new child is added. The
|
430
|
+
* `DataSnapshot` passed into the callback will reflect the data for the
|
431
|
+
* relevant child. For ordering purposes, it is passed a second argument which
|
432
|
+
* is a string containing the key of the previous sibling child by sort order,
|
433
|
+
* or `null` if it is the first child.
|
434
|
+
*
|
435
|
+
* @param query - The query to run.
|
436
|
+
* @param callback - A callback that fires when the specified event occurs.
|
437
|
+
* The callback will be passed a DataSnapshot and a string containing the key of
|
438
|
+
* the previous child, by sort order, or `null` if it is the first child.
|
439
|
+
* @param cancelCallback - An optional callback that will be notified if your
|
440
|
+
* event subscription is ever canceled because your client does not have
|
441
|
+
* permission to read this data (or it had permission but has now lost it).
|
442
|
+
* This callback will be passed an `Error` object indicating why the failure
|
443
|
+
* occurred.
|
444
|
+
* @returns A function that can be invoked to remove the listener.
|
445
|
+
*/
|
446
|
+
export function onChildAdded(
|
447
|
+
query: Query,
|
448
|
+
callback: (snapshot: DataSnapshot, previousChildName?: string | null) => unknown,
|
449
|
+
cancelCallback?: (error: Error) => unknown,
|
450
|
+
): Unsubscribe;
|
451
|
+
|
452
|
+
/**
|
453
|
+
* Listens for data changes at a particular location.
|
454
|
+
*
|
455
|
+
* This is the primary way to read data from a Database. Your callback
|
456
|
+
* will be triggered for the initial data and again whenever the data changes.
|
457
|
+
* Invoke the returned unsubscribe callback to stop receiving updates.
|
458
|
+
*
|
459
|
+
* An `onChildAdded` event will be triggered once for each initial child at this
|
460
|
+
* location, and it will be triggered again every time a new child is added. The
|
461
|
+
* `DataSnapshot` passed into the callback will reflect the data for the
|
462
|
+
* relevant child. For ordering purposes, it is passed a second argument which
|
463
|
+
* is a string containing the key of the previous sibling child by sort order,
|
464
|
+
* or `null` if it is the first child.
|
465
|
+
*
|
466
|
+
* @param query - The query to run.
|
467
|
+
* @param callback - A callback that fires when the specified event occurs.
|
468
|
+
* The callback will be passed a DataSnapshot and a string containing the key of
|
469
|
+
* the previous child, by sort order, or `null` if it is the first child.
|
470
|
+
* @param options - An object that can be used to configure `onlyOnce`, which
|
471
|
+
* then removes the listener after its first invocation.
|
472
|
+
* @returns A function that can be invoked to remove the listener.
|
473
|
+
*/
|
474
|
+
export function onChildAdded(
|
475
|
+
query: Query,
|
476
|
+
callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown,
|
477
|
+
options: ListenOptions,
|
478
|
+
): Unsubscribe;
|
479
|
+
|
480
|
+
/**
|
481
|
+
* Listens for data changes at a particular location.
|
482
|
+
*
|
483
|
+
* This is the primary way to read data from a Database. Your callback
|
484
|
+
* will be triggered for the initial data and again whenever the data changes.
|
485
|
+
* Invoke the returned unsubscribe callback to stop receiving updates.
|
486
|
+
*
|
487
|
+
* An `onChildAdded` event will be triggered once for each initial child at this
|
488
|
+
* location, and it will be triggered again every time a new child is added. The
|
489
|
+
* `DataSnapshot` passed into the callback will reflect the data for the
|
490
|
+
* relevant child. For ordering purposes, it is passed a second argument which
|
491
|
+
* is a string containing the key of the previous sibling child by sort order,
|
492
|
+
* or `null` if it is the first child.
|
493
|
+
*
|
494
|
+
* @param query - The query to run.
|
495
|
+
* @param callback - A callback that fires when the specified event occurs.
|
496
|
+
* The callback will be passed a DataSnapshot and a string containing the key of
|
497
|
+
* the previous child, by sort order, or `null` if it is the first child.
|
498
|
+
* @param cancelCallback - An optional callback that will be notified if your
|
499
|
+
* event subscription is ever canceled because your client does not have
|
500
|
+
* permission to read this data (or it had permission but has now lost it).
|
501
|
+
* This callback will be passed an `Error` object indicating why the failure
|
502
|
+
* occurred.
|
503
|
+
* @param options - An object that can be used to configure `onlyOnce`, which
|
504
|
+
* then removes the listener after its first invocation.
|
505
|
+
* @returns A function that can be invoked to remove the listener.
|
506
|
+
*/
|
507
|
+
export function onChildAdded(
|
508
|
+
query: Query,
|
509
|
+
callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown,
|
510
|
+
cancelCallback: (error: Error) => unknown,
|
511
|
+
options: ListenOptions,
|
512
|
+
): Unsubscribe;
|
513
|
+
|
514
|
+
export function onChildAdded(
|
515
|
+
query: Query,
|
516
|
+
callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown,
|
517
|
+
cancelCallbackOrListenOptions?: ((error: Error) => unknown) | ListenOptions,
|
518
|
+
options?: ListenOptions,
|
519
|
+
): Unsubscribe;
|
520
|
+
|
521
|
+
/**
|
522
|
+
* Listens for data changes at a particular location.
|
523
|
+
*
|
524
|
+
* This is the primary way to read data from a Database. Your callback
|
525
|
+
* will be triggered for the initial data and again whenever the data changes.
|
526
|
+
* Invoke the returned unsubscribe callback to stop receiving updates.
|
527
|
+
*
|
528
|
+
* An `onChildChanged` event will be triggered when the data stored in a child
|
529
|
+
* (or any of its descendants) changes. Note that a single `child_changed` event
|
530
|
+
* may represent multiple changes to the child. The `DataSnapshot` passed to the
|
531
|
+
* callback will contain the new child contents. For ordering purposes, the
|
532
|
+
* callback is also passed a second argument which is a string containing the
|
533
|
+
* key of the previous sibling child by sort order, or `null` if it is the first
|
534
|
+
* child.
|
535
|
+
*
|
536
|
+
* @param query - The query to run.
|
537
|
+
* @param callback - A callback that fires when the specified event occurs.
|
538
|
+
* The callback will be passed a DataSnapshot and a string containing the key of
|
539
|
+
* the previous child, by sort order, or `null` if it is the first child.
|
540
|
+
* @param cancelCallback - An optional callback that will be notified if your
|
541
|
+
* event subscription is ever canceled because your client does not have
|
542
|
+
* permission to read this data (or it had permission but has now lost it).
|
543
|
+
* This callback will be passed an `Error` object indicating why the failure
|
544
|
+
* occurred.
|
545
|
+
* @returns A function that can be invoked to remove the listener.
|
546
|
+
*/
|
547
|
+
export function onChildChanged(
|
548
|
+
query: Query,
|
549
|
+
callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown,
|
550
|
+
cancelCallback?: (error: Error) => unknown,
|
551
|
+
): Unsubscribe;
|
552
|
+
|
553
|
+
/**
|
554
|
+
* Listens for data changes at a particular location.
|
555
|
+
*
|
556
|
+
* This is the primary way to read data from a Database. Your callback
|
557
|
+
* will be triggered for the initial data and again whenever the data changes.
|
558
|
+
* Invoke the returned unsubscribe callback to stop receiving updates.
|
559
|
+
*
|
560
|
+
* An `onChildChanged` event will be triggered when the data stored in a child
|
561
|
+
* (or any of its descendants) changes. Note that a single `child_changed` event
|
562
|
+
* may represent multiple changes to the child. The `DataSnapshot` passed to the
|
563
|
+
* callback will contain the new child contents. For ordering purposes, the
|
564
|
+
* callback is also passed a second argument which is a string containing the
|
565
|
+
* key of the previous sibling child by sort order, or `null` if it is the first
|
566
|
+
* child.
|
567
|
+
*
|
568
|
+
* @param query - The query to run.
|
569
|
+
* @param callback - A callback that fires when the specified event occurs.
|
570
|
+
* The callback will be passed a DataSnapshot and a string containing the key of
|
571
|
+
* the previous child, by sort order, or `null` if it is the first child.
|
572
|
+
* @param options - An object that can be used to configure `onlyOnce`, which
|
573
|
+
* then removes the listener after its first invocation.
|
574
|
+
* @returns A function that can be invoked to remove the listener.
|
575
|
+
*/
|
576
|
+
export function onChildChanged(
|
577
|
+
query: Query,
|
578
|
+
callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown,
|
579
|
+
options: ListenOptions,
|
580
|
+
): Unsubscribe;
|
581
|
+
|
582
|
+
/**
|
583
|
+
* Listens for data changes at a particular location.
|
584
|
+
*
|
585
|
+
* This is the primary way to read data from a Database. Your callback
|
586
|
+
* will be triggered for the initial data and again whenever the data changes.
|
587
|
+
* Invoke the returned unsubscribe callback to stop receiving updates.
|
588
|
+
*
|
589
|
+
* An `onChildChanged` event will be triggered when the data stored in a child
|
590
|
+
* (or any of its descendants) changes. Note that a single `child_changed` event
|
591
|
+
* may represent multiple changes to the child. The `DataSnapshot` passed to the
|
592
|
+
* callback will contain the new child contents. For ordering purposes, the
|
593
|
+
* callback is also passed a second argument which is a string containing the
|
594
|
+
* key of the previous sibling child by sort order, or `null` if it is the first
|
595
|
+
* child.
|
596
|
+
*
|
597
|
+
* @param query - The query to run.
|
598
|
+
* @param callback - A callback that fires when the specified event occurs.
|
599
|
+
* The callback will be passed a DataSnapshot and a string containing the key of
|
600
|
+
* the previous child, by sort order, or `null` if it is the first child.
|
601
|
+
* @param cancelCallback - An optional callback that will be notified if your
|
602
|
+
* event subscription is ever canceled because your client does not have
|
603
|
+
* permission to read this data (or it had permission but has now lost it).
|
604
|
+
* This callback will be passed an `Error` object indicating why the failure
|
605
|
+
* occurred.
|
606
|
+
* @param options - An object that can be used to configure `onlyOnce`, which
|
607
|
+
* then removes the listener after its first invocation.
|
608
|
+
* @returns A function that can be invoked to remove the listener.
|
609
|
+
*/
|
610
|
+
export function onChildChanged(
|
611
|
+
query: Query,
|
612
|
+
callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown,
|
613
|
+
cancelCallback: (error: Error) => unknown,
|
614
|
+
options: ListenOptions,
|
615
|
+
): Unsubscribe;
|
616
|
+
|
617
|
+
export function onChildChanged(
|
618
|
+
query: Query,
|
619
|
+
callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown,
|
620
|
+
cancelCallbackOrListenOptions?: ((error: Error) => unknown) | ListenOptions,
|
621
|
+
options?: ListenOptions,
|
622
|
+
): Unsubscribe;
|
623
|
+
|
624
|
+
/**
|
625
|
+
* Listens for data changes at a particular location.
|
626
|
+
*
|
627
|
+
* This is the primary way to read data from a Database. Your callback
|
628
|
+
* will be triggered for the initial data and again whenever the data changes.
|
629
|
+
* Invoke the returned unsubscribe callback to stop receiving updates.
|
630
|
+
*
|
631
|
+
* An `onChildMoved` event will be triggered when a child's sort order changes
|
632
|
+
* such that its position relative to its siblings changes. The `DataSnapshot`
|
633
|
+
* passed to the callback will be for the data of the child that has moved. It
|
634
|
+
* is also passed a second argument which is a string containing the key of the
|
635
|
+
* previous sibling child by sort order, or `null` if it is the first child.
|
636
|
+
*
|
637
|
+
* @param query - The query to run.
|
638
|
+
* @param callback - A callback that fires when the specified event occurs.
|
639
|
+
* The callback will be passed a DataSnapshot and a string containing the key of
|
640
|
+
* the previous child, by sort order, or `null` if it is the first child.
|
641
|
+
* @param cancelCallback - An optional callback that will be notified if your
|
642
|
+
* event subscription is ever canceled because your client does not have
|
643
|
+
* permission to read this data (or it had permission but has now lost it).
|
644
|
+
* This callback will be passed an `Error` object indicating why the failure
|
645
|
+
* occurred.
|
646
|
+
* @returns A function that can be invoked to remove the listener.
|
647
|
+
*/
|
648
|
+
export function onChildMoved(
|
649
|
+
query: Query,
|
650
|
+
callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown,
|
651
|
+
cancelCallback?: (error: Error) => unknown,
|
652
|
+
): Unsubscribe;
|
653
|
+
|
654
|
+
/**
|
655
|
+
* Listens for data changes at a particular location.
|
656
|
+
*
|
657
|
+
* This is the primary way to read data from a Database. Your callback
|
658
|
+
* will be triggered for the initial data and again whenever the data changes.
|
659
|
+
* Invoke the returned unsubscribe callback to stop receiving updates.
|
660
|
+
*
|
661
|
+
* An `onChildMoved` event will be triggered when a child's sort order changes
|
662
|
+
* such that its position relative to its siblings changes. The `DataSnapshot`
|
663
|
+
* passed to the callback will be for the data of the child that has moved. It
|
664
|
+
* is also passed a second argument which is a string containing the key of the
|
665
|
+
* previous sibling child by sort order, or `null` if it is the first child.
|
666
|
+
*
|
667
|
+
* @param query - The query to run.
|
668
|
+
* @param callback - A callback that fires when the specified event occurs.
|
669
|
+
* The callback will be passed a DataSnapshot and a string containing the key of
|
670
|
+
* the previous child, by sort order, or `null` if it is the first child.
|
671
|
+
* @param options - An object that can be used to configure `onlyOnce`, which
|
672
|
+
* then removes the listener after its first invocation.
|
673
|
+
* @returns A function that can be invoked to remove the listener.
|
674
|
+
*/
|
675
|
+
export function onChildMoved(
|
676
|
+
query: Query,
|
677
|
+
callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown,
|
678
|
+
options: ListenOptions,
|
679
|
+
): Unsubscribe;
|
680
|
+
|
681
|
+
/**
|
682
|
+
* Listens for data changes at a particular location.
|
683
|
+
*
|
684
|
+
* This is the primary way to read data from a Database. Your callback
|
685
|
+
* will be triggered for the initial data and again whenever the data changes.
|
686
|
+
* Invoke the returned unsubscribe callback to stop receiving updates.
|
687
|
+
*
|
688
|
+
* An `onChildMoved` event will be triggered when a child's sort order changes
|
689
|
+
* such that its position relative to its siblings changes. The `DataSnapshot`
|
690
|
+
* passed to the callback will be for the data of the child that has moved. It
|
691
|
+
* is also passed a second argument which is a string containing the key of the
|
692
|
+
* previous sibling child by sort order, or `null` if it is the first child.
|
693
|
+
*
|
694
|
+
* @param query - The query to run.
|
695
|
+
* @param callback - A callback that fires when the specified event occurs.
|
696
|
+
* The callback will be passed a DataSnapshot and a string containing the key of
|
697
|
+
* the previous child, by sort order, or `null` if it is the first child.
|
698
|
+
* @param cancelCallback - An optional callback that will be notified if your
|
699
|
+
* event subscription is ever canceled because your client does not have
|
700
|
+
* permission to read this data (or it had permission but has now lost it).
|
701
|
+
* This callback will be passed an `Error` object indicating why the failure
|
702
|
+
* occurred.
|
703
|
+
* @param options - An object that can be used to configure `onlyOnce`, which
|
704
|
+
* then removes the listener after its first invocation.
|
705
|
+
* @returns A function that can be invoked to remove the listener.
|
706
|
+
*/
|
707
|
+
export function onChildMoved(
|
708
|
+
query: Query,
|
709
|
+
callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown,
|
710
|
+
cancelCallback: (error: Error) => unknown,
|
711
|
+
options: ListenOptions,
|
712
|
+
): Unsubscribe;
|
713
|
+
|
714
|
+
export function onChildMoved(
|
715
|
+
query: Query,
|
716
|
+
callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown,
|
717
|
+
cancelCallbackOrListenOptions?: ((error: Error) => unknown) | ListenOptions,
|
718
|
+
options?: ListenOptions,
|
719
|
+
): Unsubscribe;
|
720
|
+
|
721
|
+
/**
|
722
|
+
* Listens for data changes at a particular location.
|
723
|
+
*
|
724
|
+
* This is the primary way to read data from a Database. Your callback
|
725
|
+
* will be triggered for the initial data and again whenever the data changes.
|
726
|
+
* Invoke the returned unsubscribe callback to stop receiving updates. See
|
727
|
+
* {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
|
728
|
+
* for more details.
|
729
|
+
*
|
730
|
+
* An `onChildRemoved` event will be triggered once every time a child is
|
731
|
+
* removed. The `DataSnapshot` passed into the callback will be the old data for
|
732
|
+
* the child that was removed. A child will get removed when either:
|
733
|
+
*
|
734
|
+
* - a client explicitly calls `remove()` on that child or one of its ancestors
|
735
|
+
* - a client calls `set(null)` on that child or one of its ancestors
|
736
|
+
* - that child has all of its children removed
|
737
|
+
* - there is a query in effect which now filters out the child (because it's
|
738
|
+
* sort order changed or the max limit was hit)
|
739
|
+
*
|
740
|
+
* @param query - The query to run.
|
741
|
+
* @param callback - A callback that fires when the specified event occurs.
|
742
|
+
* The callback will be passed a DataSnapshot and a string containing the key of
|
743
|
+
* the previous child, by sort order, or `null` if it is the first child.
|
744
|
+
* @param cancelCallback - An optional callback that will be notified if your
|
745
|
+
* event subscription is ever canceled because your client does not have
|
746
|
+
* permission to read this data (or it had permission but has now lost it).
|
747
|
+
* This callback will be passed an `Error` object indicating why the failure
|
748
|
+
* occurred.
|
749
|
+
* @returns A function that can be invoked to remove the listener.
|
750
|
+
*/
|
751
|
+
export function onChildRemoved(
|
752
|
+
query: Query,
|
753
|
+
callback: (snapshot: DataSnapshot) => unknown,
|
754
|
+
cancelCallback?: (error: Error) => unknown,
|
755
|
+
): Unsubscribe;
|
756
|
+
|
757
|
+
/**
|
758
|
+
* Listens for data changes at a particular location.
|
759
|
+
*
|
760
|
+
* This is the primary way to read data from a Database. Your callback
|
761
|
+
* will be triggered for the initial data and again whenever the data changes.
|
762
|
+
* Invoke the returned unsubscribe callback to stop receiving updates. See
|
763
|
+
* {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
|
764
|
+
* for more details.
|
765
|
+
*
|
766
|
+
* An `onChildRemoved` event will be triggered once every time a child is
|
767
|
+
* removed. The `DataSnapshot` passed into the callback will be the old data for
|
768
|
+
* the child that was removed. A child will get removed when either:
|
769
|
+
*
|
770
|
+
* - a client explicitly calls `remove()` on that child or one of its ancestors
|
771
|
+
* - a client calls `set(null)` on that child or one of its ancestors
|
772
|
+
* - that child has all of its children removed
|
773
|
+
* - there is a query in effect which now filters out the child (because it's
|
774
|
+
* sort order changed or the max limit was hit)
|
775
|
+
*
|
776
|
+
* @param query - The query to run.
|
777
|
+
* @param callback - A callback that fires when the specified event occurs.
|
778
|
+
* The callback will be passed a DataSnapshot and a string containing the key of
|
779
|
+
* the previous child, by sort order, or `null` if it is the first child.
|
780
|
+
* @param options - An object that can be used to configure `onlyOnce`, which
|
781
|
+
* then removes the listener after its first invocation.
|
782
|
+
* @returns A function that can be invoked to remove the listener.
|
783
|
+
*/
|
784
|
+
export function onChildRemoved(
|
785
|
+
query: Query,
|
786
|
+
callback: (snapshot: DataSnapshot) => unknown,
|
787
|
+
options: ListenOptions,
|
788
|
+
): Unsubscribe;
|
789
|
+
|
790
|
+
/**
|
791
|
+
* Listens for data changes at a particular location.
|
792
|
+
*
|
793
|
+
* This is the primary way to read data from a Database. Your callback
|
794
|
+
* will be triggered for the initial data and again whenever the data changes.
|
795
|
+
* Invoke the returned unsubscribe callback to stop receiving updates. See
|
796
|
+
* {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
|
797
|
+
* for more details.
|
798
|
+
*
|
799
|
+
* An `onChildRemoved` event will be triggered once every time a child is
|
800
|
+
* removed. The `DataSnapshot` passed into the callback will be the old data for
|
801
|
+
* the child that was removed. A child will get removed when either:
|
802
|
+
*
|
803
|
+
* - a client explicitly calls `remove()` on that child or one of its ancestors
|
804
|
+
* - a client calls `set(null)` on that child or one of its ancestors
|
805
|
+
* - that child has all of its children removed
|
806
|
+
* - there is a query in effect which now filters out the child (because it's
|
807
|
+
* sort order changed or the max limit was hit)
|
808
|
+
*
|
809
|
+
* @param query - The query to run.
|
810
|
+
* @param callback - A callback that fires when the specified event occurs.
|
811
|
+
* The callback will be passed a DataSnapshot and a string containing the key of
|
812
|
+
* the previous child, by sort order, or `null` if it is the first child.
|
813
|
+
* @param cancelCallback - An optional callback that will be notified if your
|
814
|
+
* event subscription is ever canceled because your client does not have
|
815
|
+
* permission to read this data (or it had permission but has now lost it).
|
816
|
+
* This callback will be passed an `Error` object indicating why the failure
|
817
|
+
* occurred.
|
818
|
+
* @param options - An object that can be used to configure `onlyOnce`, which
|
819
|
+
* then removes the listener after its first invocation.
|
820
|
+
* @returns A function that can be invoked to remove the listener.
|
821
|
+
*/
|
822
|
+
export function onChildRemoved(
|
823
|
+
query: Query,
|
824
|
+
callback: (snapshot: DataSnapshot) => unknown,
|
825
|
+
cancelCallback: (error: Error) => unknown,
|
826
|
+
options: ListenOptions,
|
827
|
+
): Unsubscribe;
|
828
|
+
|
829
|
+
export function onChildRemoved(
|
830
|
+
query: Query,
|
831
|
+
callback: (snapshot: DataSnapshot) => unknown,
|
832
|
+
cancelCallbackOrListenOptions?: ((error: Error) => unknown) | ListenOptions,
|
833
|
+
options?: ListenOptions,
|
834
|
+
): Unsubscribe;
|
835
|
+
|
836
|
+
/**
|
837
|
+
* Writes data to this Database location.
|
838
|
+
*
|
839
|
+
* This will overwrite any data at this location and all child locations.
|
840
|
+
*
|
841
|
+
* The effect of the write will be visible immediately, and the corresponding
|
842
|
+
* events ("value", "child_added", etc.) will be triggered. Synchronization of
|
843
|
+
* the data to the Firebase servers will also be started, and the returned
|
844
|
+
* Promise will resolve when complete. If provided, the `onComplete` callback
|
845
|
+
* will be called asynchronously after synchronization has finished.
|
846
|
+
*
|
847
|
+
* Passing `null` for the new value is equivalent to calling `remove()`; namely,
|
848
|
+
* all data at this location and all child locations will be deleted.
|
849
|
+
*
|
850
|
+
* `set()` will remove any priority stored at this location, so if priority is
|
851
|
+
* meant to be preserved, you need to use `setWithPriority()` instead.
|
852
|
+
*
|
853
|
+
* Note that modifying data with `set()` will cancel any pending transactions
|
854
|
+
* at that location, so extreme care should be taken if mixing `set()` and
|
855
|
+
* `transaction()` to modify the same data.
|
856
|
+
*
|
857
|
+
* A single `set()` will generate a single "value" event at the location where
|
858
|
+
* the `set()` was performed.
|
859
|
+
*
|
860
|
+
* @param ref - The location to write to.
|
861
|
+
* @param value - The value to be written (string, number, boolean, object,
|
862
|
+
* array, or null).
|
863
|
+
* @returns Resolves when write to server is complete.
|
864
|
+
*/
|
865
|
+
export function set(ref: DatabaseReference, value: unknown): Promise<void>;
|
866
|
+
|
867
|
+
/**
|
868
|
+
* Sets a priority for the data at this Database location.
|
869
|
+
*
|
870
|
+
* Applications need not use priority but can order collections by
|
871
|
+
* ordinary properties
|
872
|
+
*
|
873
|
+
* @param ref - The location to write to.
|
874
|
+
* @param priority - The priority to be written (string, number, or null).
|
875
|
+
* @returns Resolves when write to server is complete.
|
876
|
+
*/
|
877
|
+
export function setPriority(
|
878
|
+
ref: DatabaseReference,
|
879
|
+
priority: string | number | null,
|
880
|
+
): Promise<void>;
|
881
|
+
|
882
|
+
/**
|
883
|
+
* Writes data the Database location. Like `set()` but also specifies the
|
884
|
+
* priority for that data.
|
885
|
+
*
|
886
|
+
* Applications need not use priority but can order collections by
|
887
|
+
* ordinary properties
|
888
|
+
*
|
889
|
+
* @param ref - The location to write to.
|
890
|
+
* @param value - The value to be written (string, number, boolean, object,
|
891
|
+
* array, or null).
|
892
|
+
* @param priority - The priority to be written (string, number, or null).
|
893
|
+
* @returns Resolves when write to server is complete.
|
894
|
+
*/
|
895
|
+
export function setWithPriority(
|
896
|
+
ref: DatabaseReference,
|
897
|
+
value: unknown,
|
898
|
+
priority: string | number | null,
|
899
|
+
): Promise<void>;
|
900
|
+
|
901
|
+
/**
|
902
|
+
* Gets the most up-to-date result for this query.
|
903
|
+
*
|
904
|
+
* @param query - The query to run.
|
905
|
+
* @returns A `Promise` which resolves to the resulting DataSnapshot if a value is
|
906
|
+
* available, or rejects if the client is unable to return a value (e.g., if the
|
907
|
+
* server is unreachable and there is nothing cached).
|
908
|
+
*/
|
909
|
+
export function get(query: Query): Promise<DataSnapshot>;
|
910
|
+
|
911
|
+
/**
|
912
|
+
* Gets a `Reference` for the location at the specified relative path.
|
913
|
+
*
|
914
|
+
* The relative path can either be a simple child name (for example, "ada") or
|
915
|
+
* a deeper slash-separated path (for example, "ada/name/first").
|
916
|
+
*
|
917
|
+
* @param parent - The parent location.
|
918
|
+
* @param path - A relative path from this location to the desired child
|
919
|
+
* location.
|
920
|
+
* @returns The specified child location.
|
921
|
+
*/
|
922
|
+
export function child(parent: DatabaseReference, path: string): DatabaseReference;
|
923
|
+
|
924
|
+
/**
|
925
|
+
* Returns an `OnDisconnect` object - see
|
926
|
+
* {@link https://firebase.google.com/docs/database/web/offline-capabilities | Enabling Offline Capabilities in JavaScript}
|
927
|
+
* for more information on how to use it.
|
928
|
+
*
|
929
|
+
* @param ref - The reference to add OnDisconnect triggers for.
|
930
|
+
*/
|
931
|
+
export function onDisconnect(ref: DatabaseReference): OnDisconnect;
|
932
|
+
|
933
|
+
/**
|
934
|
+
* By calling `keepSynced(true)` on a location, the data for that location will automatically
|
935
|
+
* be downloaded and kept in sync, even when no listeners are attached for that location.
|
936
|
+
*
|
937
|
+
* #### Example
|
938
|
+
*
|
939
|
+
* ```js
|
940
|
+
* const dbRef = ref(getDatabase(), 'users');
|
941
|
+
* await keepSynced(dbRef, true);
|
942
|
+
* ```
|
943
|
+
*
|
944
|
+
* @param ref A location to keep synchronized.
|
945
|
+
* @param bool Pass `true` to keep this location synchronized, pass `false` to stop synchronization.
|
946
|
+
*/
|
947
|
+
export function keepSynced(ref: DatabaseReference, bool: boolean): Promise<void>;
|
948
|
+
|
949
|
+
/**
|
950
|
+
* Generates a new child location using a unique key and returns its
|
951
|
+
* `Reference`.
|
952
|
+
*
|
953
|
+
* This is the most common pattern for adding data to a collection of items.
|
954
|
+
*
|
955
|
+
* If you provide a value to `push()`, the value is written to the
|
956
|
+
* generated location. If you don't pass a value, nothing is written to the
|
957
|
+
* database and the child remains empty (but you can use the `Reference`
|
958
|
+
* elsewhere).
|
959
|
+
*
|
960
|
+
* The unique keys generated by `push()` are ordered by the current time, so the
|
961
|
+
* resulting list of items is chronologically sorted. The keys are also
|
962
|
+
* designed to be unguessable (they contain 72 random bits of entropy).
|
963
|
+
*
|
964
|
+
* See {@link https://firebase.google.com/docs/database/web/lists-of-data#append_to_a_list_of_data | Append to a list of data}.
|
965
|
+
* See {@link https://firebase.googleblog.com/2015/02/the-2120-ways-to-ensure-unique_68.html | The 2^120 Ways to Ensure Unique Identifiers}.
|
966
|
+
*
|
967
|
+
* @param parent - The parent location.
|
968
|
+
* @param value - Optional value to be written at the generated location.
|
969
|
+
* @returns Combined `Promise` and `Reference`; resolves when write is complete,
|
970
|
+
* but can be used immediately as the `Reference` to the child location.
|
971
|
+
*/
|
972
|
+
export function push(parent: DatabaseReference, value?: unknown): ThenableReference;
|
973
|
+
|
974
|
+
/**
|
975
|
+
* Removes the data at this Database location.
|
976
|
+
*
|
977
|
+
* Any data at child locations will also be deleted.
|
978
|
+
*
|
979
|
+
* The effect of the remove will be visible immediately and the corresponding
|
980
|
+
* event 'value' will be triggered. Synchronization of the remove to the
|
981
|
+
* Firebase servers will also be started, and the returned Promise will resolve
|
982
|
+
* when complete. If provided, the onComplete callback will be called
|
983
|
+
* asynchronously after synchronization has finished.
|
984
|
+
*
|
985
|
+
* @param ref - The location to remove.
|
986
|
+
* @returns Resolves when remove on server is complete.
|
987
|
+
*/
|
988
|
+
export function remove(ref: DatabaseReference): Promise<void>;
|
989
|
+
|
990
|
+
/**
|
991
|
+
* Writes multiple values to the Database at once.
|
992
|
+
*
|
993
|
+
* The `values` argument contains multiple property-value pairs that will be
|
994
|
+
* written to the Database together. Each child property can either be a simple
|
995
|
+
* property (for example, "name") or a relative path (for example,
|
996
|
+
* "name/first") from the current location to the data to update.
|
997
|
+
*
|
998
|
+
* As opposed to the `set()` method, `update()` can be use to selectively update
|
999
|
+
* only the referenced properties at the current location (instead of replacing
|
1000
|
+
* all the child properties at the current location).
|
1001
|
+
*
|
1002
|
+
* The effect of the write will be visible immediately, and the corresponding
|
1003
|
+
* events ('value', 'child_added', etc.) will be triggered. Synchronization of
|
1004
|
+
* the data to the Firebase servers will also be started, and the returned
|
1005
|
+
* Promise will resolve when complete. If provided, the `onComplete` callback
|
1006
|
+
* will be called asynchronously after synchronization has finished.
|
1007
|
+
*
|
1008
|
+
* A single `update()` will generate a single "value" event at the location
|
1009
|
+
* where the `update()` was performed, regardless of how many children were
|
1010
|
+
* modified.
|
1011
|
+
*
|
1012
|
+
* Note that modifying data with `update()` will cancel any pending
|
1013
|
+
* transactions at that location, so extreme care should be taken if mixing
|
1014
|
+
* `update()` and `transaction()` to modify the same data.
|
1015
|
+
*
|
1016
|
+
* Passing `null` to `update()` will remove the data at this location.
|
1017
|
+
*
|
1018
|
+
* See
|
1019
|
+
* {@link https://firebase.googleblog.com/2015/09/introducing-multi-location-updates-and_86.html | Introducing multi-location updates and more}.
|
1020
|
+
*
|
1021
|
+
* @param ref - The location to write to.
|
1022
|
+
* @param values - Object containing multiple values.
|
1023
|
+
* @returns Resolves when update on server is complete.
|
1024
|
+
*/
|
1025
|
+
export function update(ref: DatabaseReference, values: object): Promise<void>;
|