DataSnapshot
A DataSnapshot
contains data from a Database location.
Any time you read data from the Database, you receive the data as a DataSnapshot
. A DataSnapshot
is passed to the event callbacks you attach with on()
or once()
. You can extract the contents
of the snapshot as a JavaScript object by calling the val() method. Alternatively, you can traverse
into the snapshot by calling child()
to return child snapshots (which you could then call val()
on).
Properties
Methods
child
</>Gets another DataSnapshot
for the location at the specified relative path.
child(path: string): DataSnapshot;
exists
</>Returns true if this DataSnapshot
contains any data. It is slightly more efficient than using snapshot.val() !== null.
exists(): boolean;
exportVal
</>Exports the entire contents of the DataSnapshot as a JavaScript object.
exportVal(): any;
getPriority
</>Gets the priority value of the data in this DataSnapshot.
getPriority(): string | number | null;
hasChild
</>Returns true if the specified child path has (non-null) data.
hasChild(path: string): boolean;
hasChildren
</>Returns whether or not the DataSnapshot
has any non-null child properties.
hasChildren(): boolean;