Macro worker::query

source ·
macro_rules! query {
    ($db:expr, $query:expr) => { ... };
    ($db:expr, $query:expr, $($args:expr),* $(,)?) => { ... };
}
Expand description

Requires d1 feature. Prepare a D1 query from the provided D1Database, query string, and optional query parameters.

Any parameter provided is required to implement serde::Serialize to be used.

Using query is equivalent to using db.prepare(‘’).bind(‘’) in Javascript.

§Example

let query = worker::query!(
  &d1,
  "SELECT * FROM things WHERE num > ?1 AND num < ?2",
  &min,
  &max,
)?;