chyabrung-cli 0.2.5

The `chy` command line tool for Chyabrung: scaffolding, dev server with hot reload, builds, generators, migrations and one-command deploys
use chyabrung::prelude::*;

#[model]
pub struct Post {
    pub id: i64,
    pub user_id: i64,
    pub title: String,
    pub body: String,
    pub published: bool,
    #[belongs_to]
    pub author: Option<super::User>,
    pub created_at: Option<Timestamp>,
    pub updated_at: Option<Timestamp>,
}

impl Post {
    pub fn can_be_changed_by(&self, user: &Identity, permission: &str) -> bool {
        user.id == self.user_id.to_string() || user.can(permission)
    }
}