[go: up one dir, main page]

D1PreparedStatement

Struct D1PreparedStatement 

Source
pub struct D1PreparedStatement(/* private fields */);

Implementations§

Source§

impl D1PreparedStatement

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn run(&self) -> Result<D1Result>

Executes a query against the database but only return metadata.

Source

pub async fn all(&self) -> Result<D1Result>

Executes a query against the database and returns all rows and metadata.

Source

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.

Source

pub async fn raw_js_value(&self) -> Result<Vec<JsValue>>

Executes a query against the database and returns a Vec of JsValues.

Source

pub fn inner(&self) -> &D1PreparedStatementSys

Returns the inner JsValue bindings object.

Trait Implementations§

Source§

impl Clone for D1PreparedStatement

Source§

fn clone(&self) -> D1PreparedStatement

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for D1PreparedStatement

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<D1PreparedStatement> for D1PreparedStatement

Source§

fn from(inner: D1PreparedStatementSys) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,