#[repr(transparent)]
pub struct Database { /* private fields */ }
Expand description

Implementations§

Order the query

Order query result by column.

#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
struct OrderOptions {
    foreign_table: String,
    nulls_first: bool,
    ascending: bool,
}
let data: JsValue = client
.get()
.from("countries")
.select_(Some("name, cities ( name )"))
.order(
   "name",
   serde_wasm_bindgen::to_value(&OrderOptions {
    foreign_table: "cities".to_string(),
    nulls_first: false,
    ascending: true,
   }).unwrap(),
)
.await.unwrap();
Limit the query

Limit the query result by count.

Limit the query to a range

Limit the query result by from and to inclusively.

Retrieve the query as one row

Return data as a single object instead of an array of objects.

Retrieve the query as 0-1 rows

Return data as a single object instead of an array of objects.

Retrieve the query as a CSV string

Return data as a string in CSV format.

let csv = client.get().from("countries").select_(Some("*")).csv().await.unwrap();
Column is equal to a value

Match only rows where column is equal to value.

Column is not equal to a value

Match only rows where column is not equal to value.

Column is greater than a value

Match only rows where column is greater than value.

Column is greater than or equal to a value

Match only rows where column is greater than or equal to value.

Column is less than a value

Match only rows where column is less than value.

Column is less than or equal to a value

Match only rows where column is less than or equal to value.

Column matches a pattern

Match only rows where column matches pattern case-sensitively.

Column matches a case-insensitive pattern

Match only rows where column matches pattern case-insensitively.

client.from("countries").select(None).ilike(&"name", &"%alba%").await;
Column is a value

Match only rows where column IS value.

// check for nullness
client.from("countries").select(None).is("name", JsValue::NULL);
// or check for true of false
client.from("countries").select(None).is("name", JsValue::TRUE);
Column is in an array

Match only rows where column is included in the values array.

Column contains every element in a value

Only relevant for jsonb, array, and range columns. Match only rows where column contains every element appearing in value.

Contained by value

Only relevant for jsonb, array, and range columns. Match only rows where every element appearing in column is contained by value.

Greater than a range

Only relevant for range columns. Match only rows where every element in column is greater than any element in range.

Greater than or equal to a range

Only relevant for range columns. Match only rows where every element in column is either contained in range or greater than any element in range.

Less than a range

Only relevant for range columns. Match only rows where every element in column is less than any element in range.

Less than or equal to a range

Only relevant for range columns. Match only rows where every element in column is either contained in range or less than any element in range.

Mutually exclusive to a range

Only relevant for range columns. Match only rows where column is mutually exclusive to range and there can be no element between the two ranges.

With a common element

Only relevant for array and range columns. Match only rows where column and value have an element in common.

Match a string

Only relevant for text and tsvector columns. Match only rows where column matches the query string in query.

Update data

Perform an UPDATE on the table or view.

Upsert data

Perform an UPSERT on the table or view.

Delete data

Should always be combined with filters

let client = supabase_js_rs::create_client("https://xyzcompany.supabase.co", "public-anon-key");
let res: Result<JsValue, JsValue> = client.from("countries").delete().eq("id", 1.into_js_result().unwrap()).await;
Insert data

Perform an INSERT into the table or view.

Methods from Deref<Target = JsValue>§

Returns the f64 value of this JS value if it’s an instance of a number.

If this JS value is not an instance of a number then this returns None.

Tests whether this JS value is a JS string.

If this JS value is a string value, this function copies the JS string value into wasm linear memory, encoded as UTF-8, and returns it as a Rust String.

To avoid the copying and re-encoding, consider the JsString::try_from() function from js-sys instead.

If this JS value is not an instance of a string or if it’s not valid utf-8 then this returns None.

UTF-16 vs UTF-8

JavaScript strings in general are encoded as UTF-16, but Rust strings are encoded as UTF-8. This can cause the Rust string to look a bit different than the JS string sometimes. For more details see the documentation about the str type which contains a few caveats about the encodings.

Returns the bool value of this JS value if it’s an instance of a boolean.

If this JS value is not an instance of a boolean then this returns None.

Tests whether this JS value is null

Tests whether this JS value is undefined

Tests whether the type of this JS value is symbol

Tests whether typeof self == "object" && self !== null.

Tests whether the type of this JS value is function.

Tests whether the type of this JS value is bigint.

Applies the unary typeof JS operator on a JsValue.

MDN documentation

Applies the binary in JS operator on the two JsValues.

MDN documentation

Tests whether the value is “truthy”.

Tests whether the value is “falsy”.

Compare two JsValues for equality, using the == operator in JS.

MDN documentation

Applies the unary ~ JS operator on a JsValue.

MDN documentation

Applies the binary >>> JS operator on the two JsValues.

MDN documentation

Applies the binary / JS operator on two JsValues, catching and returning any RangeError thrown.

MDN documentation

Applies the binary ** JS operator on the two JsValues.

MDN documentation

Applies the binary < JS operator on the two JsValues.

MDN documentation

Applies the binary <= JS operator on the two JsValues.

MDN documentation

Applies the binary >= JS operator on the two JsValues.

MDN documentation

Applies the binary > JS operator on the two JsValues.

MDN documentation

Applies the unary + JS operator on a JsValue. Can throw.

MDN documentation

Trait Implementations§

Converts this type into a shared reference of the (usually inferred) input type.
Converts this type into a shared reference of the (usually inferred) input type.
The resulting type after dereferencing.
Dereferences the value.
Converts to this type from the input type.
Converts to this type from the input type.
The wasm ABI type that this converts from when coming back out from the ABI boundary.
Recover a Self from Self::Abi. Read more
The wasm ABI type that this converts into when crossing the ABI boundary.
Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
The wasm ABI type that this converts into when crossing the ABI boundary.
Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Performs a dynamic instanceof check to see whether the JsValue provided is an instance of this type. Read more
Performs a zero-cost unchecked conversion from a JsValue into an instance of Self Read more
Performs a zero-cost unchecked conversion from a &JsValue into an instance of &Self. Read more
Test whether this JS value has a type T. Read more
Performs a dynamic cast (checked at runtime) of this value into the target type T. Read more
Performs a dynamic cast (checked at runtime) of this value into the target type T. Read more
Performs a zero-cost unchecked cast into the specified type. Read more
Performs a zero-cost unchecked cast into a reference to the specified type. Read more
Test whether this JS value is an instance of the type T. Read more
Performs a dynamic check to see whether the JsValue provided is a value of this type. Read more
Tests whether the argument is a “none” instance. If so it will be deserialized as None, and otherwise it will be passed to FromWasmAbi.
Returns an ABI instance indicating “none”, which JS will interpret as the None branch of this option. Read more
Returns an ABI instance indicating “none”, which JS will interpret as the None branch of this option. Read more
The wasm ABI type references to Self are recovered from.
The type that holds the reference to Self for the duration of the invocation of the function that has an &Self parameter. This is required to ensure that the lifetimes don’t persist beyond one function call, and so that they remain anonymous.
Recover a Self::Anchor from Self::Abi. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Same as IntoWasmAbi::Abi
Same as IntoWasmAbi::into_abi, except that it may throw and never return in the case of Err.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.