mirror of
https://github.com/supabase/supabase.git
synced 2026-07-02 03:54:22 +08:00
86 lines
1.7 KiB
Plaintext
86 lines
1.7 KiB
Plaintext
---
|
|
id: order
|
|
title: 'order()'
|
|
slug: /order
|
|
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v2_legacy.yml
|
|
---
|
|
|
|
import Tabs from '@theme/Tabs'
|
|
import TabItem from '@theme/TabItem'
|
|
|
|
Orders the result with the specified `column`.
|
|
|
|
```js
|
|
const { data, error } = await supabase
|
|
.from('cities')
|
|
.select('name', 'country_id')
|
|
.order('id', { ascending: false })
|
|
```
|
|
|
|
## Parameters
|
|
|
|
<ul className="method-list-group">
|
|
|
|
<li className="method-list-item">
|
|
<h4 className="method-list-item-label">
|
|
<span className="method-list-item-label-name">
|
|
column
|
|
</span>
|
|
<span className="method-list-item-label-badge required">
|
|
required
|
|
</span>
|
|
<span className="method-list-item-validation">
|
|
<code>ColumnName</code>
|
|
</span>
|
|
</h4>
|
|
<div class="method-list-item-description">
|
|
|
|
The column to order on.
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<li className="method-list-item">
|
|
<h4 className="method-list-item-label">
|
|
<span className="method-list-item-label-name">
|
|
options
|
|
</span>
|
|
<span className="method-list-item-label-badge false">
|
|
optional
|
|
</span>
|
|
<span className="method-list-item-validation">
|
|
<code>object</code>
|
|
</span>
|
|
</h4>
|
|
<div class="method-list-item-description">
|
|
|
|
No description provided.
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
## Examples
|
|
|
|
### With `select()`
|
|
|
|
```js
|
|
const { data, error } = await supabase
|
|
.from('cities')
|
|
.select('name', 'country_id')
|
|
.order('id', { ascending: false })
|
|
```
|
|
|
|
### With embedded resources
|
|
|
|
```js
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select('name, cities(name)')
|
|
.eq('name', 'United States')
|
|
.order('name', { foreignTable: 'cities' })
|
|
```
|