Home > @firebase/firestore > / > orderBy
orderBy() function
Creates a QueryConstraint
that sorts the query result by the specified field, optionally in descending order instead of ascending.
Signature:
export declare function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDirection): QueryConstraint;
Parameters
Parameter | Type | Description |
---|---|---|
fieldPath | string | FieldPath | The field to sort by. |
directionStr | OrderByDirection | Optional direction to sort by ('asc' or 'desc'). If not specified, order will be ascending. |
Returns:
The created Query
.