limit()

Limit the query result by count.

1const { data, error } = await supabase
2  .from('countries')
3  .select('name')
4  .limit(1)

Parameters#

  • countrequired
    number

    The maximum number of rows to return

  • optionsrequired
    object

    Named parameters

      Properties
    • foreignTableoptional
      string

      Set this to limit rows of foreign tables instead of the current table

Examples#

With select()#

1create table
2  countries (id int8 primary key, name text);
3
4insert into
5  countries (id, name)
6values
7  (1, 'Afghanistan'),
8  (2, 'Albania'),
9  (3, 'Algeria');

On a foreign table#

1create table
2  countries (id int8 primary key, name text);
3create table
4  cities (
5    id int8 primary key,
6    country_id int8 not null references countries,
7    name text
8  );
9
10insert into
11  countries (id, name)
12values
13  (1, 'United States');
14insert into
15  cities (id, country_id, name)
16values
17  (1, 1, 'Atlanta'),
18  (2, 1, 'New York City');