RuleDataSnapshot
Presentation
This is the JavaScript object type of predefined variables data
, newData
and root
.
Methods
val()
- No argument
- return value: the value of the data node (as a JavaScript
number
,boolean
,string
or JSON object) ornull
if the data node has no value.
child()
- Arguments:
childPath
:string
- return value: a
RuleDataSnapshot
at the sub-path given bychildPath
.
ThechildPath
may include several path segments separated by the"/"
character, as well as the"."
and".."
relative path segments.
parent()
- No argument
- return value: a
RuleDataSnapshot
instance representing the parent data node.
hasChild()
- Arguments:
childPath
:string
- return value: a
boolean
indicating if a child at the sub-path given bychildPath
exists (i.e. has a non-null value)
childCount()
- No argument
- return value: a
number
representing the child count of the data node, or 0 if it is not an object.
hasChildren()
- Arguments:
- (optional)
children
: array ofstring
- (optional)
- return value: a
boolean
indicating if:- at least one child exists (if no
children
argument is passed), - a child exists at each sub-path given in the
children
argument.
- at least one child exists (if no
exists()
- No argument
- return value: a
boolean
indicating whether this data node has a non-null value (if so, theval()
function returns a non-null value).
isNumber()
- No argument
- return value: a
boolean
indicating if the data node has a value and this value is a number.
isString()
- No argument
- return value: a
boolean
indicating if the data node has a value and this value is a string.
isBoolean()
- No argument
- return value: a
boolean
indicating if the data node has a value and this value is a boolean.
hash()
- No argument
- return value: a
string
containing the "hash value" of the (complete) node. That is a unique string value that can be used to test node equality or if a node has changed.