The Firebase JS SDK is now in BETA!
This EAP site is no longer maintained. See the official Firebase Documentation site for the latest documentation and information about the Firebase JS SDK.

Home > @firebase/database > push

push() function

Generates a new child location using a unique key and returns its Reference.

This is the most common pattern for adding data to a collection of items.

If you provide a value to push(), the value is written to the generated location. If you don't pass a value, nothing is written to the database and the child remains empty (but you can use the Reference elsewhere).

The unique keys generated by push() are ordered by the current time, so the resulting list of items is chronologically sorted. The keys are also designed to be unguessable (they contain 72 random bits of entropy).

See Append to a list of data
See The 2^120 Ways to Ensure Unique Identifiers

Signature:

export declare function push(parent: Reference, value?: unknown): ThenableReference;

Parameters

Parameter Type Description
parent Reference The parent location.
value unknown Optional value to be written at the generated location.

Returns:

ThenableReference

Combined Promise and Reference; resolves when write is complete, but can be used immediately as the Reference to the child location.