rust_d1_orm/model.rs
1use worker::wasm_bindgen::JsValue;
2
3pub trait D1Model: Sized + for<'de> serde::Deserialize<'de> {
4 const TABLE: &'static str;
5 const COLUMNS: &'static [&'static str];
6 fn values(&self) -> Vec<JsValue>;
7}
8
9pub fn opt_js<T: Into<JsValue>>(val: Option<T>) -> JsValue {
10 val.map(Into::into).unwrap_or(JsValue::NULL)
11}