<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@firebase/firestore](./firestore.md) &gt; [lite](./firestore_lite.md) &gt; [limitToLast](./firestore_lite.limittolast.md)

## limitToLast() function

Creates a `QueryConstraint` that only returns the last matching documents.

You must specify at least one `orderBy` clause for `limitToLast` queries, otherwise an exception will be thrown during execution.

<b>Signature:</b>

```typescript
export declare function limitToLast(limit: number): QueryConstraint;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  limit | number | The maximum number of items to return. |

<b>Returns:</b>

[QueryConstraint](./firestore_lite.queryconstraint.md)

The created `Query`<!-- -->.

