콘솔로 이동

A Reference represents a specific location in your Database and can be used for reading or writing data to that Database location.

You can reference the root or child location in your Database by calling firebase.database().ref() or firebase.database().ref("child/path").

Writing is done with the set() method and reading can be done with the on() method. See Read and Write Data on the Web

Index

Properties

key

key: string | null

The last part of the Reference's path.

For example, "ada" is the key for https://<DATABASE_NAME>.firebaseio.com/users/ada.

The key of a root Reference is null.

example
// The key of a root reference is null
var rootRef = firebase.database().ref();
var key = rootRef.key;  // key === null
example
// The key of any non-root reference is the last token in the path
var adaRef = firebase.database().ref("users/ada");
var key = adaRef.key;  // key === "ada"
key = adaRef.child("name/last").key;  // key === "last"

parent

parent: Reference | null

The parent location of a Reference.

The parent of a root Reference is null.

example
// The parent of a root reference is null
var rootRef = firebase.database().ref();
parent = rootRef.parent;  // parent === null
example
// The parent of any non-root reference is the parent location
var usersRef = firebase.database().ref("users");
var adaRef = firebase.database().ref("users/ada");
// usersRef and adaRef.parent represent the same location

ref

Returns a Reference to the Query's location.

root

root: