sea-orm-adapter

Crates.iosea-orm-adapter
lib.rssea-orm-adapter
version0.4.0
sourcesrc
created_at2023-01-16 09:54:31.336291
updated_at2024-08-06 01:26:41.410402
descriptionSea ORM adapter for casbin-rs
homepagehttps://github.com/ZihanType/sea-orm-adapter
repositoryhttps://github.com/ZihanType/sea-orm-adapter
max_upload_size
id760043
size32,200
ZihanType (ZihanType)

documentation

README

sea-orm-adapter

Crates.io version

Sea ORM Adapter is the Sea ORM adapter for Casbin-rs. With this library, Casbin can load policy from Sea ORM supported database or save policy to it with fully asynchronous support.

Based on Sea ORM, The current supported databases are:

Example

use casbin::{CoreApi, DefaultModel, Enforcer};
use sea_orm::Database;
use sea_orm_adapter::SeaOrmAdapter;

#[tokio::main]
async fn main() {
    let m = DefaultModel::from_file("examples/rbac_model.conf")
        .await
        .unwrap();

    let db = Database::connect("mysql://root:123456@localhost:3306/casbin")
        .await
        .unwrap();

    let a = SeaOrmAdapter::new(db).await.unwrap();
    let e = Enforcer::new(m, a).await.unwrap();
}
Commit count: 21

cargo fmt