poem-sea-orm-middleware

Crates.iopoem-sea-orm-middleware
lib.rspoem-sea-orm-middleware
version0.5.2
sourcesrc
created_at2023-02-08 03:10:24.882129
updated_at2024-05-22 02:31:57.600335
descriptionSea ORM middleware for Poem web framework
homepagehttps://github.com/ZihanType/poem-sea-orm-middleware
repositoryhttps://github.com/ZihanType/poem-sea-orm-middleware
max_upload_size
id779295
size69,739
ZihanType (ZihanType)

documentation

README

poem-sea-orm-middleware

Crates.io version

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.

Example

#[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.

Commit count: 19

cargo fmt