Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public class PostgrestQuery
- Object
- PostgrestQuery
A PostgREST query or write on one table, built with chained calls and
sent by execute().
Filters apply to selects, updates and deletes. Values are sent as text; PostgREST converts them to the column type.
Supabase supabase = new Supabase("https://xyzcompany.supabase.co", "public-anon-key");
Map<String, Object> row = new HashMap<String, Object>();
row.put("name", "Denmark");
supabase.from("countries").insert(row).returning(true).execute();
supabase.from("countries").delete().eq("name", "Atlantis").execute();Methods
Inherited methods
Method details
select
public PostgrestQuery select(String columns)Chooses the columns to return,
* by default. Embedded resources
work too: id,name,cities(name).Parameters
columnsString- the column list
Returns
this query
eq
public PostgrestQuery eq(String column, Object value)Column equals value.
Parameters
columnString- the column
valueObject- the value
Returns
this query
neq
public PostgrestQuery neq(String column, Object value)Column does not equal value.
Parameters
columnString- the column
valueObject- the value
Returns
this query
gt
public PostgrestQuery gt(String column, Object value)Column is greater than value.
Parameters
columnString- the column
valueObject- the value
Returns
this query
gte
public PostgrestQuery gte(String column, Object value)Column is greater than or equal to value.
Parameters
columnString- the column
valueObject- the value
Returns
this query
lt
public PostgrestQuery lt(String column, Object value)Column is less than value.
Parameters
columnString- the column
valueObject- the value
Returns
this query
lte
public PostgrestQuery lte(String column, Object value)Column is less than or equal to value.
Parameters
columnString- the column
valueObject- the value
Returns
this query
like
public PostgrestQuery like(String column, String pattern)Case sensitive pattern match. Use
* or % as the wildcard.Parameters
columnString- the column
patternString- the pattern
Returns
this query
ilike
public PostgrestQuery ilike(String column, String pattern)Case insensitive pattern match.
Parameters
columnString- the column
patternString- the pattern
Returns
this query
is
public PostgrestQuery is(String column, String value)Column
IS a value: null, true or false.Parameters
columnString- the column
valueStringnull,trueorfalse
Returns
this query
in
public PostgrestQuery in(String column, Object... values)Column is one of the values. Values with commas, quotes or
parentheses are quoted.
Parameters
columnString- the column
valuesObject...- the values
Returns
this query
order
public PostgrestQuery order(String column, boolean ascending)Sorts by a column. Call again for secondary sorts.
Parameters
columnString- the column
ascendingboolean- the direction
Returns
this query
limit
public PostgrestQuery limit(int count)Returns at most
count rows.Parameters
countint- the row limit
Returns
this query
range
public PostgrestQuery range(int from, int to)Returns rows
from to to, both inclusive and zero based.Parameters
fromint- the first row
toint- the last row
Returns
this query
insert
public PostgrestQuery insert(Object rows)Inserts a row (
Map) or rows (List of maps).Parameters
rowsObject- a map or a list of maps
Returns
this query
upsert
public PostgrestQuery upsert(Object rows, String onConflictColumns)Inserts rows or merges them into existing rows with the same key.
Parameters
rowsObject- a map or a list of maps
onConflictColumnsString- the unique columns to match on, or null for the primary key
Returns
this query
update
public PostgrestQuery update(Map<String, Object> values)Updates the rows that match the filters.
Parameters
valuesMap<String, Object>- the columns to change
Returns
this query
delete
public PostgrestQuery delete()Deletes the rows that match the filters.
Returns
this query
returning
public PostgrestQuery returning(boolean returning)Asks a write to return the affected rows. Off by default.
Parameters
returningboolean- true to return the rows
Returns
this query
getMethod
public String getMethod()The HTTP method
execute() sends.Returns
the method
buildUrl
public String buildUrl()The request URL
execute() sends, query string included.Returns
the URL
buildHeaders
public Map<String, String> buildHeaders()The request headers
execute() adds to the auth headers.Returns
the headers
execute
public AsyncResource<List<Map<String, Object>>> execute()Sends the request.
Returns
the rows; empty for a write without
returning(true)