So the diesel operations are blocking the actix Routers, On the other hand, The sea ORM doesn't have any blocking code because sea ORM is an async ORM, but diesel Dont has async support.
Let's Implement an example router and insert some data into the database.
diesel
fn example_router() -> impl Responder {
let result = web::block(|| {
let new_account: Account = NewAccount {
username: &new_org_info.username,
account_type: &String::from("organization"),
}
.insert_into(app_accounts)
.get_result(&mut conn)
.unwrap()
}).await.unwrap();
}
sea ORM
fn example_router() -> impl Responder {
let pear = fruit::ActiveModel {
name: Set("Pear".to_owned()),
..Default::default() // all other attributes are `NotSet`
};
let pear: fruit::Model = pear.insert(db).await.unwrap();
}
As you can see sea ORM version is pretty simple and readable.
Change The ORM?
Sea ORM?
So the diesel operations are blocking the actix Routers, On the other hand, The sea ORM doesn't have any blocking code because sea ORM is an async ORM, but diesel Dont has async support.
Let's Implement an example router and insert some data into the database.
diesel
sea ORM
As you can see sea ORM version is pretty simple and readable.