glibsql/libsql

glibsql/libsql helps construct and eexecute a libSQL request.

Types

Config encapsulates everything needed to construct a libSQL client.

see new_client() to construct this record.

pub opaque type Config

Error type for all possible errors returned by glibsql/http.

pub opaque type GlibsqlError

LibsqlClient encapsulates everything needed to interact with a libSQL server.

see build() to construct this record.

pub type LibsqlClient

Represents a response from a libSQL query.

The records parameter is the type of the rows returned by the query.

pub opaque type LibsqlResponse(records)

Functions

pub fn build(
  config: Config,
) -> Result(LibsqlClient, GlibsqlError)

Build the libSQL client using the previously provided values.

pub fn execute(
  query: String,
  on client: LibsqlClient,
  returning decoder: Decoder(a),
) -> Promise(Result(LibsqlResponse(a), GlibsqlError))

Execute a query against the database.

Returns a LibsqlResponse containing

  • the number of rows affected
  • the last insert rowid
  • the rows returned by the query (decoded using the provided decoder)
pub fn new_client() -> Config

Create a new libSQL client.

Uses the builder pattern to construct everything necessary to start a client.

pub fn with_token(client: Config, token: String) -> Config

Set the Bearer token to access the database. Do not include Bearer . Calling this function multiple times will override the previous value.

pub fn with_url(client: Config, url: String) -> Config

Set the target database URL. Calling this function multiple times will override the previous value.

Search Document