orma 0.3.3

A PostgreSQL ORM written in Rust language
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use orma::*;
use serde::{Deserialize, Serialize};

#[orma_obj(table = "intrared.groups")]
#[derive(Serialize, Deserialize)]
pub struct Group {
    pub name: String,
    pub description: Option<String>,
}

impl Group {
    pub async fn find_by_name(
        db_conn: &Connection,
        name: &str,
    ) -> Result<Option<DbEntity<Group>>, DbError> {
        DbEntity::<Group>::find_by(db_conn, ("data->>'name'=$1", &[&name])).await
    }
}