Crates.io | poem-sea-orm-middleware |
lib.rs | poem-sea-orm-middleware |
version | 0.7.1 |
source | src |
created_at | 2023-02-08 03:10:24.882129 |
updated_at | 2024-09-24 07:03:10.912065 |
description | Sea ORM middleware for Poem web framework |
homepage | https://github.com/ZihanType/poem-sea-orm-middleware |
repository | https://github.com/ZihanType/poem-sea-orm-middleware |
max_upload_size | |
id | 779295 |
size | 73,048 |
This library is the Sea ORM middleware for Poem. This library is designed to make it easier for users to no longer need to manually begin transactions.
#[handler]
async fn hello(Path(name): Path<String>) -> String {
// get transaction from task local
let txn = default_txn().await.unwrap();
let user = match Entity::find()
.filter(Column::Name.eq(name.clone()))
.one(&txn)
.await
.unwrap()
{
Some(user) => user,
None => return format!("not found: {name}"),
};
format!("hello: {}", user.name)
}
Check examples, to see the full examples.