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.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more