res://addons/w4gd/supabase/poly_result.gd:PolyResult

Inherits: RefCounted

The result of most requests to Supabase.

Description

PolyResult wraps some piece of data, which can be almost any type, including Object, ResultError, Dictionary, Array, PackedByteArray, String, int, float, or bool. Use the is_*() methods (like is_dict() to check the type, or the as_*() methods (like as_dict() to get the data in the given type (or some "zero" version of that type if it's a different type). You can also refer to sub-properties of the wrapped data, and get them as a new PolyResult object. For example:

var dict := {
  key = "a string"
}
var result = PolyResult.new(dict)
print(result.key.as_string())

Methods

Array

as_array ( )

bool

as_bool ( )

PackedByteArray

as_bytes ( )

Dictionary

as_dict ( )

res://addons/w4gd/supabase/poly_result.gd:ResultError

as_error ( )

float

as_float ( )

int

as_int ( )

String

as_string ( )

void

get_at ( int idx )

void

get_data ( )

Dictionary

get_headers ( )

void

get_http_result ( )

bool

is_array ( )

bool

is_bool ( )

bool

is_byte_array ( )

bool

is_dict ( )

bool

is_empty ( )

bool

is_error ( )

bool

is_float ( )

bool

is_int ( )

bool

is_null ( )

bool

is_string ( )

Array

keys ( )

int

size ( )

Array

values ( )


Method Descriptions

Array as_array ( )

Returns the wrapped data as an Array. If the wrapped data isn't an Array, it will return an empty Array.


bool as_bool ( )

Returns the wrapped data as a bool. If the wrapped data is a int or float, it will be converted to a bool. If the wrapped data isn't a bool or any of those, it will return false.


PackedByteArray as_bytes ( )

Returns the wrapped data as a PackedByteArray. If the wrapped data isn't a PackedByteArray, it will return an empty PackedByteArray.


Dictionary as_dict ( )

Returns the wrapped data as a Dictionary. If the wrapped data isn't a Dictionary, it will return an empty Dictionary.


res://addons/w4gd/supabase/poly_result.gd:ResultError as_error ( )

Returns the wrapped data as a ResultError. If the wrapped data isn't a ResultError, it will return null.


float as_float ( )

Returns the wrapped data as a float. If the wrapped data is a bool or int, it will be converted to a float. If the wrapped data isn't a float or any of those, it will return 0.0.


int as_int ( )

Returns the wrapped data as an int. If the wrapped data is a bool or float, it will be converted to an int. If the wrapped data isn't an int or any of those, it will return 0.


String as_string ( )

Returns the wrapped data as a String. If the wrapped data is a bool, int or float, it will be converted to a String. If the wrapped data isn't a String or any of those, it will return an empty String.


void get_at ( int idx )

Returns a new PolyResult for the item at the given index. If the wrapped data isn't an Array or PackedByteArray, or the index is out of bounds, it will return a wrapped ResultError object.


void get_data ( )

Returns the wrapped data.


Dictionary get_headers ( )

Returns the headers from the HTTP result associated with this PolyResult. If there is no associated HTTP result, it will return an empty Dictionary.


void get_http_result ( )

Returns the HTTP result associated with this PolyResult. If there is no associated HTTP result, it will return null.


bool is_array ( )

Returns true if the wrapped data is an Array; otherwise, false.


bool is_bool ( )

Returns true if the wrapped data is a bool; otherwise, false.


bool is_byte_array ( )

Returns true if the wrapped data is a PackedByteArray; otherwise, false.


bool is_dict ( )

Returns true if the wrapped data is a Dictionary; otherwise, false.


bool is_empty ( )

Returns true if the wrapped data is empty; otherwise, false.


bool is_error ( )

Returns true if the wrapped data is a ResultError; otherwise, false.


bool is_float ( )

Returns true if the wrapped data is a float; otherwise, false.


bool is_int ( )

Returns true if the wrapped data is an int; otherwise, false.


bool is_null ( )

Returns true if the wrapped data is null; otherwise, false.


bool is_string ( )

Returns true if the wrapped data is a string; otherwise, false.


Array keys ( )

Returns an Array of the keys from the wrapped data. If the wrapped data isn't a Dictionary, it will return an empty Array.


int size ( )

Returns the size or length of the wrapped data. If the wrapped data isn't a Dictionary, Array or String, it will return 0;


Array values ( )

Returns an Array of the values from the wrapped data. If the wrapped data isn't an Array or Dictionary, it will return an empty Array.