Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public class PostgrestQuery

  1. Object
  2. 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

public PostgrestQuery select(String columns)Chooses the columns to return, * by default.
public PostgrestQuery eq(String column, Object value)Column equals value.
public PostgrestQuery neq(String column, Object value)Column does not equal value.
public PostgrestQuery gt(String column, Object value)Column is greater than value.
public PostgrestQuery gte(String column, Object value)Column is greater than or equal to value.
public PostgrestQuery lt(String column, Object value)Column is less than value.
public PostgrestQuery lte(String column, Object value)Column is less than or equal to value.
public PostgrestQuery like(String column, String pattern)Case sensitive pattern match.
public PostgrestQuery ilike(String column, String pattern)Case insensitive pattern match.
public PostgrestQuery is(String column, String value)Column IS a value: null, true or false.
public PostgrestQuery in(String column, Object... values)Column is one of the values.
public PostgrestQuery order(String column, boolean ascending)Sorts by a column.
public PostgrestQuery limit(int count)Returns at most count rows.
public PostgrestQuery range(int from, int to)Returns rows from to to, both inclusive and zero based.
public PostgrestQuery insert(Object rows)Inserts a row (Map) or rows (List of maps).
public PostgrestQuery upsert(Object rows, String onConflictColumns)Inserts rows or merges them into existing rows with the same key.
public PostgrestQuery update(Map<String, Object> values)Updates the rows that match the filters.
public PostgrestQuery delete()Deletes the rows that match the filters.
public PostgrestQuery returning(boolean returning)Asks a write to return the affected rows.
public String getMethod()The HTTP method execute() sends.
public String buildUrl()The request URL execute() sends, query string included.
public Map<String, String> buildHeaders()The request headers execute() adds to the auth headers.
public AsyncResource<List<Map<String, Object>>> execute()Sends the request.

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

columns String
the column list

Returns

this query

eq

public PostgrestQuery eq(String column, Object value)
Column equals value.

Parameters

column String
the column
value Object
the value

Returns

this query

neq

public PostgrestQuery neq(String column, Object value)
Column does not equal value.

Parameters

column String
the column
value Object
the value

Returns

this query

gt

public PostgrestQuery gt(String column, Object value)
Column is greater than value.

Parameters

column String
the column
value Object
the value

Returns

this query

gte

public PostgrestQuery gte(String column, Object value)
Column is greater than or equal to value.

Parameters

column String
the column
value Object
the value

Returns

this query

lt

public PostgrestQuery lt(String column, Object value)
Column is less than value.

Parameters

column String
the column
value Object
the value

Returns

this query

lte

public PostgrestQuery lte(String column, Object value)
Column is less than or equal to value.

Parameters

column String
the column
value Object
the value

Returns

this query

like

public PostgrestQuery like(String column, String pattern)
Case sensitive pattern match. Use * or % as the wildcard.

Parameters

column String
the column
pattern String
the pattern

Returns

this query

ilike

public PostgrestQuery ilike(String column, String pattern)
Case insensitive pattern match.

Parameters

column String
the column
pattern String
the pattern

Returns

this query

is

public PostgrestQuery is(String column, String value)
Column IS a value: null, true or false.

Parameters

column String
the column
value String
null, true or false

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

column String
the column
values Object...
the values

Returns

this query

order

public PostgrestQuery order(String column, boolean ascending)
Sorts by a column. Call again for secondary sorts.

Parameters

column String
the column
ascending boolean
the direction

Returns

this query

limit

public PostgrestQuery limit(int count)
Returns at most count rows.

Parameters

count int
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

from int
the first row
to int
the last row

Returns

this query

insert

public PostgrestQuery insert(Object rows)
Inserts a row (Map) or rows (List of maps).

Parameters

rows Object
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

rows Object
a map or a list of maps
onConflictColumns String
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

values Map<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

returning boolean
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)