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 fn new(url: impl Into<String>, token: impl Into<String>) -> Self
pub fn new(url: impl Into<String>, token: impl Into<String>) -> 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
source§impl Client
impl Client
pub async fn raw_batch( &self, stmts: impl IntoIterator<Item = impl Into<Statement>> ) -> Result<BatchResult>
pub async fn execute(&self, stmt: impl Into<Statement>) -> Result<ResultSet>
pub async fn execute_in_transaction( &self, tx_id: u64, stmt: Statement ) -> Result<ResultSet>
pub async fn commit_transaction(&self, tx_id: u64) -> Result<()>
pub async fn rollback_transaction(&self, tx_id: u64) -> Result<()>
Trait Implementations§
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