order()
Orders the result with the specified column
.
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.order('id', { ascending: false })
Parameters
columnrequired
object
The column to order on.
__namedParametersrequired
object
No description provided.
nullsFirstrequired
boolean
If
true
,null
s appear first.foreignTablerequired
undefined
|string
The foreign table to use (if
column
is a foreign column).ascendingrequired
boolean
If
true
, the result will be in ascending order.
Properties
Examples
With select()
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.order('id', { ascending: false })
With embedded resources
const { data, error } = await supabase
.from('countries')
.select('name, cities(name)')
.eq('name', 'United States')
.order('name', {foreignTable: 'cities'})
Ordering multiple columns
const { data, error } = await supabase
.from('cities')
.select('name', 'country_id')
.order('country_id', { ascending: false })
.order('name', { ascending: false })