mirror of
https://github.com/supabase/supabase.git
synced 2026-07-03 01:34:31 +08:00
86 lines
1.6 KiB
Plaintext
86 lines
1.6 KiB
Plaintext
---
|
|
id: limit
|
|
title: 'limit()'
|
|
slug: /limit
|
|
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'
|
|
|
|
Limits the result with the specified `count`.
|
|
|
|
```js
|
|
const { data, error } = await supabase
|
|
.from('cities')
|
|
.select('name, country_id')
|
|
.limit(1)
|
|
```
|
|
|
|
## Parameters
|
|
|
|
<ul className="method-list-group">
|
|
|
|
<li className="method-list-item">
|
|
<h4 className="method-list-item-label">
|
|
<span className="method-list-item-label-name">
|
|
count
|
|
</span>
|
|
<span className="method-list-item-label-badge required">
|
|
required
|
|
</span>
|
|
<span className="method-list-item-validation">
|
|
<code>number</code>
|
|
</span>
|
|
</h4>
|
|
<div class="method-list-item-description">
|
|
|
|
The maximum no. of rows to limit to.
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<li className="method-list-item">
|
|
<h4 className="method-list-item-label">
|
|
<span className="method-list-item-label-name">
|
|
foreignTable
|
|
</span>
|
|
<span className="method-list-item-label-badge required">
|
|
required
|
|
</span>
|
|
<span className="method-list-item-validation">
|
|
<code>object</code>
|
|
</span>
|
|
</h4>
|
|
<div class="method-list-item-description">
|
|
|
|
The foreign table to use (for foreign columns).
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
## Examples
|
|
|
|
### With `select()`
|
|
|
|
```js
|
|
const { data, error } = await supabase
|
|
.from('cities')
|
|
.select('name, country_id')
|
|
.limit(1)
|
|
```
|
|
|
|
### With embedded resources
|
|
|
|
```js
|
|
const { data, error } = await supabase
|
|
.from('countries')
|
|
.select('name, cities(name)')
|
|
.eq('name', 'United States')
|
|
.limit(1, { foreignTable: 'cities' })
|
|
```
|