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

```rust /// explicit transaction

[handler]

async fn hello( Path(name): Path, // get transaction from parameter rather than task local Data(txn): Data<&ArcTxn>, ) -> String { let txn = &**txn;

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)

}

/// implicit transaction

[handler]

async fn hello(Path(name): Path) -> String { // get transaction from task local rather than passing it as a parameter let txn = &*TXN.cloned();

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.