Skip to main content

d1

Function d1 

Source
pub fn d1(name: &str) -> Result<D1Database, CfError>
Expand description

Access a D1 database binding by name.

Shorthand for cf::env().d1(name).cf()?.

§Errors

Returns CfError if the binding is missing or not a D1 database.

§Example

use dioxus_cloudflare::prelude::*;

#[server]
pub async fn get_user(id: String) -> Result<User, ServerFnError> {
    let db = cf::d1("DB")?;
    // ...
}