pub struct D1PreparedStatement(/* private fields */);
Implementations§
source§impl D1PreparedStatement
impl D1PreparedStatement
sourcepub fn bind(self, values: &[JsValue]) -> Result<Self>
pub fn bind(self, values: &[JsValue]) -> Result<Self>
Bind one or more parameters to the statement. Consumes the old statement and returns a new statement with the bound parameters.
D1 follows the SQLite convention for prepared statements parameter binding.
§Considerations
Supports Ordered (?NNNN) and Anonymous (?) parameters - named parameters are currently not supported.
sourcepub fn bind_refs<'a, T: IntoIterator<Item = &'a U>, U: D1Argument + 'a>(
&self,
values: T,
) -> Result<Self>
pub fn bind_refs<'a, T: IntoIterator<Item = &'a U>, U: D1Argument + 'a>( &self, values: T, ) -> Result<Self>
Bind one or more parameters to the statement. Returns a new statement with the bound parameters, leaving the old statement available for reuse.
sourcepub fn batch_bind<'a, U: IntoIterator<Item = &'a V> + 'a, T: IntoIterator<Item = U> + 'a, V: D1Argument + 'a>(
&self,
values: T,
) -> Result<Vec<Self>>
pub fn batch_bind<'a, U: IntoIterator<Item = &'a V> + 'a, T: IntoIterator<Item = U> + 'a, V: D1Argument + 'a>( &self, values: T, ) -> Result<Vec<Self>>
Bind a batch of parameter values, returning a batch of prepared statements.
Result can be passed to D1Database::batch
to execute the statements.
sourcepub async fn first<T>(&self, col_name: Option<&str>) -> Result<Option<T>>where
T: for<'a> Deserialize<'a>,
pub async fn first<T>(&self, col_name: Option<&str>) -> Result<Option<T>>where
T: for<'a> Deserialize<'a>,
Return the first row of results.
If col_name
is Some
, returns that single value, otherwise returns the entire object.
If the query returns no rows, then this will return None
.
If the query returns rows, but column does not exist, then this will return an Err
.
sourcepub async fn run(&self) -> Result<D1Result>
pub async fn run(&self) -> Result<D1Result>
Executes a query against the database but only return metadata.
sourcepub async fn all(&self) -> Result<D1Result>
pub async fn all(&self) -> Result<D1Result>
Executes a query against the database and returns all rows and metadata.
sourcepub async fn raw<T>(&self) -> Result<Vec<Vec<T>>>where
T: for<'a> Deserialize<'a>,
pub async fn raw<T>(&self) -> Result<Vec<Vec<T>>>where
T: for<'a> Deserialize<'a>,
Executes a query against the database and returns a Vec
of rows instead of objects.
sourcepub async fn raw_js_value(&self) -> Result<Vec<JsValue>>
pub async fn raw_js_value(&self) -> Result<Vec<JsValue>>
Executes a query against the database and returns a Vec
of JsValues.
sourcepub fn inner(&self) -> &D1PreparedStatementSys
pub fn inner(&self) -> &D1PreparedStatementSys
Returns the inner JsValue bindings object.
Trait Implementations§
source§impl Clone for D1PreparedStatement
impl Clone for D1PreparedStatement
source§fn clone(&self) -> D1PreparedStatement
fn clone(&self) -> D1PreparedStatement
1.6.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl From<D1PreparedStatement> for D1PreparedStatement
impl From<D1PreparedStatement> for D1PreparedStatement
source§fn from(inner: D1PreparedStatementSys) -> Self
fn from(inner: D1PreparedStatementSys) -> Self
Auto Trait Implementations§
impl Freeze for D1PreparedStatement
impl RefUnwindSafe for D1PreparedStatement
impl !Send for D1PreparedStatement
impl !Sync for D1PreparedStatement
impl Unpin for D1PreparedStatement
impl UnwindSafe for D1PreparedStatement
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)