UNPKG

voluptasmollitia

Version:
36 lines (20 loc) 1.62 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@firebase/database](./database.md) &gt; [push](./database.push.md) ## 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](https://firebase.google.com/docs/database/web/lists-of-data#append_to_a_list_of_data) </br>See [The 2^120 Ways to Ensure Unique Identifiers](ttps://firebase.googleblog.com/2015/02/the-2120-ways-to-ensure-unique_68.html) <b>Signature:</b> ```typescript export declare function push(parent: Reference, value?: unknown): ThenableReference; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | | parent | [Reference](./database.reference.md) | The parent location. | | value | unknown | Optional value to be written at the generated location. | <b>Returns:</b> [ThenableReference](./database.thenablereference.md) Combined `Promise` and `Reference`<!-- -->; resolves when write is complete, but can be used immediately as the `Reference` to the child location.