Struct libsql_client::workers::Client
source · pub struct Client { /* private fields */ }Expand description
Database client. This is the main structure used to communicate with the database.
Implementations§
source§impl Client
impl Client
sourcepub async fn new(
url: impl Into<String>,
token: impl Into<String>
) -> Result<Self>
pub async fn new( url: impl Into<String>, token: impl Into<String> ) -> Result<Self>
Creates a database client with JWT authentication.
Arguments
url- URL of the database endpointtoken- auth token
sourcepub async fn from_config(config: Config) -> Result<Self>
pub async fn from_config(config: Config) -> Result<Self>
Creates a database client from a Config object.
sourcepub async fn from_url<T: TryInto<Url>>(url: T) -> Result<Client>where
<T as TryInto<Url>>::Error: Display,
pub async fn from_url<T: TryInto<Url>>(url: T) -> Result<Client>where <T as TryInto<Url>>::Error: Display,
sourcepub async fn from_ctx<D>(ctx: &RouteContext<D>) -> Result<Self>
pub async fn from_ctx<D>(ctx: &RouteContext<D>) -> Result<Self>
Establishes a database client from Cloudflare Workers context. Expects the context to contain the following secrets defined:
LIBSQL_CLIENT_URLLIBSQL_CLIENT_USERLIBSQL_CLIENT_PASS
Arguments
ctx- Cloudflare Workers route context
Trait Implementations§
source§impl DatabaseClient for Client
impl DatabaseClient for Client
source§fn raw_batch<'life0, 'async_trait>(
&'life0 self,
stmts: impl 'async_trait + IntoIterator<Item = impl 'async_trait + Into<Statement>>
) -> Pin<Box<dyn Future<Output = Result<BatchResult>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn raw_batch<'life0, 'async_trait>( &'life0 self, stmts: impl 'async_trait + IntoIterator<Item = impl 'async_trait + Into<Statement>> ) -> Pin<Box<dyn Future<Output = Result<BatchResult>> + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Executes a batch of SQL statements.
Each statement is going to run in its own transaction,
unless they’re wrapped in BEGIN and END Read more
source§fn execute<'life0, 'async_trait>(
&'life0 self,
stmt: impl 'async_trait + Into<Statement>
) -> Pin<Box<dyn Future<Output = Result<ResultSet>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute<'life0, 'async_trait>( &'life0 self, stmt: impl 'async_trait + Into<Statement> ) -> Pin<Box<dyn Future<Output = Result<ResultSet>> + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Executes a single SQL statement Read more
source§fn batch<'life0, 'async_trait>(
&'life0 self,
stmts: impl 'async_trait + IntoIterator<Item = impl 'async_trait + Into<Statement>>
) -> Pin<Box<dyn Future<Output = Result<Vec<ResultSet>>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn batch<'life0, 'async_trait>( &'life0 self, stmts: impl 'async_trait + IntoIterator<Item = impl 'async_trait + Into<Statement>> ) -> Pin<Box<dyn Future<Output = Result<Vec<ResultSet>>> + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Executes a batch of SQL statements, wrapped in “BEGIN”, “END”, transaction-style.
Each statement is going to run in its own transaction,
unless they’re wrapped in BEGIN and END Read more
source§fn transaction<'a, 'async_trait>(
&'a self
) -> Pin<Box<dyn Future<Output = Result<Transaction<'a, Self>>> + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
fn transaction<'a, 'async_trait>( &'a self ) -> Pin<Box<dyn Future<Output = Result<Transaction<'a, Self>>> + 'async_trait>>where Self: 'async_trait, 'a: 'async_trait,
Starts an interactive transaction and returns a
Transaction object.
The object can be later used to execute(), commit() or rollback()
the interactive transaction.Auto Trait Implementations§
impl RefUnwindSafe for Client
impl !Send for Client
impl !Sync for Client
impl Unpin for Client
impl UnwindSafe for Client
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more