UNPKG

voluptasmollitia

Version:
29 lines (16 loc) 1.35 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@firebase/database](./database.md) &gt; [limitToLast](./database.limittolast.md) ## limitToLast() function Creates a new `QueryConstraint` that is limited to return only the last specified number of children. The `limitToLast()` method is used to set a maximum number of children to be synced for a given callback. If we set a limit of 100, we will initially only receive up to 100 `child_added` events. If we have fewer than 100 messages stored in our Database, a `child_added` event will fire for each message. However, if we have over 100 messages, we will only receive a `child_added` event for the last 100 ordered messages. As items change, we will receive `child_removed` events for each item that drops out of the active list so that the total number stays at 100. You can read more about `limitToLast()` in [Filtering data](https://firebase.google.com/docs/database/web/lists-of-data#filtering_data)<!-- -->. <b>Signature:</b> ```typescript export declare function limitToLast(limit: number): QueryConstraint; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | | limit | number | The maximum number of nodes to include in this query. | <b>Returns:</b> [QueryConstraint](./database.queryconstraint.md)