Files
supabase/apps/temp-docs/docs/reference/javascript/limit.mdx
2022-04-26 14:17:19 +02:00

165 lines
2.7 KiB
Plaintext

---
id: limit
title: "limit()"
slug: limit
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
---
import Tabs from '@theme/Tabs';
import TabsPanel from '@theme/TabsPanel';
Limits the result with the specified `count`.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.limit(1)
```
</TabsPanel>
</Tabs>
## 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">
__namedParameters
</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">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<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>undefined</code> | <code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The foreign table to use (for foreign columns).
</div>
</li>
</ul>
</li>
</ul>
## Examples
### With `select()`
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.limit(1)
```
</TabsPanel>
</Tabs>
### With embedded resources
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data, error } = await supabase
.from('countries')
.select('name, cities(name)')
.eq('name', 'United States')
.limit(1, { foreignTable: 'cities' })
```
</TabsPanel>
</Tabs>