3个版本
0.1.2 | 2022年11月14日 |
---|---|
0.1.1 | 2022年11月14日 |
0.1.0 | 2022年11月12日 |
#1163 在 数据库接口
18KB
429 行
用法
- 执行字符串
let v = "insert into mobile {id:123,num:123}"
.execute_one::<Mobile>()
.await;
或引用
#[async_trait]
pub trait StrDb {
async fn execute_silent(&self) -> bool;
async fn raw_execute_one(&self) -> Result<Vec<Value>, Error>;
async fn execute_one<T: TryFrom<SurrealValue>>(&self) -> Vec<T>
where
<T as TryFrom<SurrealValue>>::Error: std::error::Error,
<T as TryFrom<SurrealValue>>::Error: Send,
<T as TryFrom<SurrealValue>>::Error: Sync,
<T as TryFrom<SurrealValue>>::Error: 'static;
}
- 测试SQL
#[cfg(test)]
#[derive(SurrealDbObject, Debug, Clone)]
pub struct App {
pub name: String,
}
#[cfg(test)]
mod test {
use crate::*;
fn instance() -> App {
App {
name: "adf".to_owned(),
}
}
smethod!(
format("create app CONTENT {}", instance, instance),
App,
create_app
);
// delete would return [] all ways
// create as test would return value, so it is no need aa get_app
smethod!(
format("delete app where name='{}'", instance, instance.name),
App,
delete,
[create_app][get_app]
);
smethod!(
format(
"select * from app where name = '{}'",
instance,
instance.name
),
App,
get_app
);
}
检查快照文件以查找功能
- 过滤集过滤器!(r"[0-9a-zA-Z]{20}\b", "[UID]",);
发布
cargo release publish --workspace --execute
测试
cargo insta test --review --delete-unreferenced-snapshots
依赖
~85MB
~1.5M SLoC