Skip to content

struct

Query

pub struct Query {
    /* private fields */
}

A PostgREST query: filters, ordering and paging, then [Query::get], [Query::insert], [Query::update], [Query::upsert] or [Query::delete].

Methods

select

pub fn select(self, columns: &str) -> Query

Columns (PostgREST syntax, including embedded relations: "id,title,author(name)").

eq

pub fn eq(self, column: &str, value: &str) -> Query

Rows where column equals value.

neq

pub fn neq(self, column: &str, value: &str) -> Query

Rows where column isn't value.

gt

pub fn gt(self, column: &str, value: &str) -> Query

Rows where column is greater than value.

gte

pub fn gte(self, column: &str, value: &str) -> Query

Rows where column is at least value.

lt

pub fn lt(self, column: &str, value: &str) -> Query

Rows where column is less than value.

lte

pub fn lte(self, column: &str, value: &str) -> Query

Rows where column is at most value.

like

pub fn like(self, column: &str, pattern: &str) -> Query

SQL LIKE; % may be written as *.

ilike

pub fn ilike(self, column: &str, pattern: &str) -> Query

Case-insensitive LIKE.

is

pub fn is(self, column: &str, value: &str) -> Query

IS NULL / IS TRUE / IS FALSE.

in_list

pub fn in_list(self, column: &str, values: &[&str]) -> Query

Rows where column is one of values.

search

pub fn search(self, column: &str, query: &str) -> Query

Full-text search (websearch_to_tsquery).

raw

pub fn raw(self, key: &str, value: &str) -> Query

Any filter, in PostgREST syntax: .raw("or", "(a.eq.1,b.eq.2)").

order

pub fn order(self, column: &str, ascending: bool) -> Query

Order by column, ascending or descending.

limit

pub fn limit(self, n: usize) -> Query

At most n rows.

offset

pub fn offset(self, n: usize) -> Query

Skip the first n rows.

count

pub fn count(self) -> Query

Ask for the total row count too (read it with total_count).

get

pub fn get(&self) -> Request

Read the matching rows.

insert

pub fn insert(&self, rows: &Json) -> Request

Insert a row (an object) or rows (an array); returns them.

upsert

pub fn upsert(&self, rows: &Json) -> Request

Insert, or update rows whose primary key already exists.

update

pub fn update(&self, changes: &Json) -> Request

Update the matching rows (add a filter first!); returns them.

delete

pub fn delete(&self) -> Request

Delete the matching rows (add a filter first!); returns them.

Trait implementations