Files
supabase/apps/reference/_supabase_js/generated/single.mdx
T
Bobbie Soedirgo a7a56eb800 docs(reference/v2/postgrest-js): update spec
* `curl -sS https://supabase.github.io/postgrest-js/spec.json >
spec/enrichments/tsdoc_v2/postgrest.json`
* `cd spec && make transform generate.js.v2 format`
2022-09-20 16:34:12 +08:00

35 lines
650 B
Plaintext

---
id: single
title: 'single()'
slug: /single
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'
Return `data` as a single object instead of an array of objects.
Query result must be one row (e.g. using `.limit(1)`), otherwise this
returns an error.
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.limit(1)
.single()
```
## Examples
### With `select()`
```js
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.limit(1)
.single()
```