Crate async_sea_orm_session

Source
Expand description

An async-session backend implemented using sea-orm, heavily inspired by async-sqlx-session.

§Basic usage

In the following example we create a DatabaseSessionStore, which implements the SessionStore trait from async_session.

use async_sea_orm_session::migration::Migrator;
use async_sea_orm_session::DatabaseSessionStore;
use sea_orm::{Database, DatabaseConnection};
use sea_orm_migration::MigratorTrait;

#[tokio::main]
async fn main() -> Result<(), sea_orm::DbErr> {
    // Create a sea_orm::DatabaseConnection in the usual way.
    let db: DatabaseConnection =
        Database::connect("protocol://username:password@host/database").await?;

    // Run the async_sea_orm_session migration to create the session table.
    Migrator::up(&db, None).await?;

    // Finally create a DatabaseSessionStore that implements SessionStore.
    let store = DatabaseSessionStore::new(db);
    Ok(())
}

§Examples

For examples see the README in the repository.

§License

Licensed under either of

at your option.

Modules§

migrationmigration
This module contains migrations to help adding the sessions table required for this crate.
prelude
This module exports DatabaseSessionStore and migration utilities. In addition, useful traits and types from both async_session and sea_orm_migration are re-rexported.

Structs§

DatabaseSessionStore