Struct worker::d1::D1Database
source · pub struct D1Database(/* private fields */);
Implementations§
source§impl D1Database
impl D1Database
sourcepub fn prepare<T: Into<String>>(&self, query: T) -> D1PreparedStatement
pub fn prepare<T: Into<String>>(&self, query: T) -> D1PreparedStatement
Prepare a query statement from a query string.
sourcepub async fn batch(
&self,
statements: Vec<D1PreparedStatement>
) -> Result<Vec<D1Result>>
pub async fn batch( &self, statements: Vec<D1PreparedStatement> ) -> Result<Vec<D1Result>>
Batch execute one or more statements against the database.
Returns the results in the same order as the provided statements.
sourcepub async fn exec(&self, query: &str) -> Result<D1ExecResult>
pub async fn exec(&self, query: &str) -> Result<D1ExecResult>
Execute one or more queries directly against the database.
The input can be one or multiple queries separated by \n
.
§Considerations
This method can have poorer performance (prepared statements can be reused in some cases) and, more importantly, is less safe. Only use this method for maintenance and one-shot tasks (example: migration jobs).
If an error occurs, an exception is thrown with the query and error messages, execution stops and further statements are not executed.
Trait Implementations§
source§impl AsRef<JsValue> for D1Database
impl AsRef<JsValue> for D1Database
source§impl EnvBinding for D1Database
impl EnvBinding for D1Database
source§impl From<D1Database> for D1Database
impl From<D1Database> for D1Database
source§fn from(inner: D1DatabaseSys) -> Self
fn from(inner: D1DatabaseSys) -> Self
Converts to this type from the input type.
source§impl From<D1Database> for JsValue
impl From<D1Database> for JsValue
source§fn from(database: D1Database) -> Self
fn from(database: D1Database) -> Self
Converts to this type from the input type.
source§impl JsCast for D1Database
impl JsCast for D1Database
source§fn instanceof(val: &JsValue) -> bool
fn instanceof(val: &JsValue) -> bool
Performs a dynamic
instanceof
check to see whether the JsValue
provided is an instance of this type. Read moresource§fn unchecked_from_js(val: JsValue) -> Self
fn unchecked_from_js(val: JsValue) -> Self
source§fn unchecked_from_js_ref(val: &JsValue) -> &Self
fn unchecked_from_js_ref(val: &JsValue) -> &Self
source§fn has_type<T>(&self) -> boolwhere
T: JsCast,
fn has_type<T>(&self) -> boolwhere
T: JsCast,
Test whether this JS value has a type
T
. Read moresource§fn dyn_into<T>(self) -> Result<T, Self>where
T: JsCast,
fn dyn_into<T>(self) -> Result<T, Self>where
T: JsCast,
Performs a dynamic cast (checked at runtime) of this value into the
target type
T
. Read moresource§fn dyn_ref<T>(&self) -> Option<&T>where
T: JsCast,
fn dyn_ref<T>(&self) -> Option<&T>where
T: JsCast,
Performs a dynamic cast (checked at runtime) of this value into the
target type
T
. Read moresource§fn unchecked_into<T>(self) -> Twhere
T: JsCast,
fn unchecked_into<T>(self) -> Twhere
T: JsCast,
Performs a zero-cost unchecked cast into the specified type. Read more
source§fn unchecked_ref<T>(&self) -> &Twhere
T: JsCast,
fn unchecked_ref<T>(&self) -> &Twhere
T: JsCast,
Performs a zero-cost unchecked cast into a reference to the specified
type. Read more
impl Send for D1Database
impl Sync for D1Database
Auto Trait Implementations§
impl Freeze for D1Database
impl RefUnwindSafe for D1Database
impl Unpin for D1Database
impl UnwindSafe for D1Database
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