Naar console

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




key: string | null

The last part of the Reference's path.

For example, "ada" is the key for https://<DATABASE_NAME>

The key of a root Reference is null.

// The key of a root reference is null
var rootRef = firebase.database().ref();
var key = rootRef.key;  // key === null
// 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: Reference | null

The parent location of a Reference.

The parent of a root Reference is null.

// The parent of a root reference is null
var rootRef = firebase.database().ref();
parent = rootRef.parent;  // parent === null
// 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


Returns a Reference to the Query's location.


root: Reference

The root Reference of the Database.

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



  • child(path: string): Reference
  • Gets a Reference for the location at the specified relative path.

    The relative path can either be a simple child name (for example, "ada") or a deeper slash-separated path (for example, "ada/name/first").

    var usersRef = firebase.database().ref('users');
    var adaRef = usersRef.child('ada');
    var adaFirstNameRef = adaRef.child('name/first');
    var path = adaFirstNameRef.toString();
    // path is now ''


    • path: string

      A relative path from this location to the desired child location.

    Returns Reference

    The specified child location.


  • endAt(value: number | string | boolean | null, key?: string): Query
  • Creates a Query with the specified ending point.

    Using startAt(), endAt(), and equalTo() allows you to choose arbitrary starting and ending points for your queries.

    The ending point is inclusive, so children with exactly the specified value will be included in the query. The optional key argument can be used to further limit the range of the query. If it is specified, then children that have exactly the specified value must also have a key name less than or equal to the specified key.

    You can read more about endAt() in Filtering data.

    // Find all dinosaurs whose names come before Pterodactyl lexicographically.
    var ref = firebase.database().ref("dinosaurs");
    ref.orderByKey().endAt("pterodactyl").on("child_added", function(snapshot) {


    • value: number | string | boolean | null