seaorm-up / schema

a common package for app with surreal
0 stars 0 forks source link

feat: support array as field #2

Open huang12zheng opened 2 years ago

huang12zheng commented 2 years ago

the trait bound account_manage::Account: std::convert::From<app_db_schema::SurrealValue> is not satisfied required for app_db_schema::SurrealValue to implement Into<account_manage::Account>

pub struct Account {
    // pub id: Thing,
    pub name: String,
    pub mobile: Vec<u64>,
}

#[cfg(test)]
fn instance() -> Account {
    Account {
        name: "hz".to_owned(),
        mobile: Vec::new(),
    }
}

smethod!(
    format(
        "select * from account where name='{}'",
        instance,
        instance.name
    ),
    Account,
    get
);
huang12zheng commented 2 years ago
[
        Object(
            Object(
                {
                    "id": Thing(
                        Thing {
                            tb: "account",
                            id: String(
                                "lta4upc9vg42w3mkb4rt",
                            ),
                        },
                    ),
                    "mobile": Array(
                        Array(
                            [
                                Number(
                                    Int(
                                        17682318150,
                                    ),
                                ),
                            ],
                        ),
                    ),
                    "name": Strand(
                        Strand(
                            "hz",
                        ),
                    ),
                },
            ),
        ),
    ],
)
huang12zheng commented 2 years ago
huang12zheng commented 2 years ago

maybe just use serde would work?

huang12zheng commented 2 years ago

there just have i32 in surrealdb, so u64 is difficult to work