final data = await supabase
.from('cities')
.select('name, country_id')
.eq('name', 'The Shire'); // Correct
final data = await supabase
.from('cities')
.eq('name', 'The Shire') // Incorrect
.select('name, country_id');
过滤器必须在select()
, update()
、upsert()
、delete()
和rpc()
之后,并在修改器之前应用。
final data = await supabase
.from('cities')
.select('name, country_id')
.gte('population', 1000)
.lt('population', 10000)
过滤器必须在select()
, update()
、upsert()
、delete()
和rpc()
之后,并在修改器之前应用。
final filterByName = null;
final filterPopLow = 1000;
final filterPopHigh = 10000;
var query = supabase
.from('cities')
.select('name, country_id');
if (filterByName != null) { query = query.eq('name', filterByName); }
if (filterPopLow != null) { query = query.gte('population', filterPopLow); }
if (filterPopHigh != null) { query = query.lt('population', filterPopHigh); }
final data = await query;
过滤器可以一步步建立起来,然后执行。这个例子就可以很好地说明。
create table
users (
id int8 primary key,
name text,
address jsonb
);
insert into
users (id, name, address)
values
(1, 'Michael', '{ "postcode": 90210 }'),
(2, 'Jane', null);
final data = await supabase
.from('users')
.select()
.eq('address->postcode', 90210);
{
"data": [
{
"id": 1,
"name": "Michael",
"address": {
"postcode": 90210
}
}
],
"status": 200,
"statusText": "OK"
}
过滤器可以一步步建立起来,然后执行。这个例子就可以很好地说明。