app-db-schema

Crates.ioapp-db-schema
lib.rsapp-db-schema
version0.1.2
sourcesrc
created_at2022-11-12 02:58:59.356491
updated_at2022-11-14 17:58:21.038252
descriptiona common package for app with surreal
homepage
repositoryhttps://github.com/seaorm-up/schema
max_upload_size
id713302
size20,027
(huang12zheng)

documentation

README

usage

  • execute str
let v = "insert into mobile {id:123,num:123}"
        .execute_one::<Mobile>()
        .await;

or something ref to

#[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;
}
  • test 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
    );
}

check snapshots files to find features

  • filter set_filters!(r"[0-9a-zA-Z]{20}\b", "[UID]",);

release

cargo release publish --workspace --execute

test

cargo insta test  --review --delete-unreferenced-snapshots
Commit count: 12

cargo fmt