use serde::Deserialize; use std::collections::BTreeMap; use surrealdb::sql::Value; #[derive(Default, Deserialize, Debug, Clone)] pub struct Params { #[serde(flatten)] pub inner: BTreeMap, } impl Params { pub fn parse(self) -> BTreeMap { self.into() } } impl From for BTreeMap { fn from(v: Params) -> BTreeMap { v.inner .into_iter() .map(|(k, v)| (k, surrealdb::sql::json(&v).unwrap_or_else(|_| Value::from(v)))) .collect::>() } }