REST from your database catalog
    DocumentationCheat sheetQuestionsDownloadSource
    Questions
    • How do I...?
    Start here
    • Getting started
    • What a table becomes
    • Compared with PostgREST
    Setting up
    • Tables, columns and relations
    • Security and hooks
    • Writes and procedures
    • Prefer: return=representation
    • Node, Fastify, Express
    Reading
    • select
    • /{key}
    • relation(...)
    • order
    • limit, offset
    • relation.order, .limit
    • count
    • count(), sum(), avg()...
    • "name"
    Filtering
    • eq, neq
    • gt, gte, lt, lte
    • in
    • like, ilike
    • match, imatch
    • is
    • ov, cs, cd
    • not
    • relation.column
    • or, and
    Databases
    • Supported databases
    • Adding a database
    Reference
    • Cheat sheet
    • Errors
    Reading

    Sort the rows

    Sort by one or more columns, ascending or descending.

    order=nameorder=estimate.descorder=estimate.asc.nullsfirstorder=owner.name,steps.count.desc

    Each term is a column with asc (the default) or desc, then optionally nullsfirst or nullslast. Without those, nulls come last going up and first going down, on every database.

    You can sort by a to-one related column, like owner.name, and by how many related rows a to-many relation has, like steps.count.

    The key is always added as a last term, so rows that tie keep the same order from one page to the next.

    Examples

    Longest first. Going down, the todo without an estimate leads.
    /todos?select=name,estimate&order=estimate.desc

    Asking the database...

    Shortest first, with the missing estimate moved to the front.
    /todos?select=name,estimate&order=estimate.asc.nullsfirst

    Asking the database...

    By owner's name, Z to A; the todo nobody owns leads.
    /todos?select=name,owner(name)&order=owner.name.desc

    Asking the database...

    The todo with the most steps first.
    /todos?select=name,steps(title)&order=steps.count.desc

    Asking the database...

    See alsoRead a page Sort and page what is embedded
    PreviousBring related rows alongNext Read a page
    restloom - a REST API generated from your database catalog
    DocumentationDownloadSource