rustauth-sqlx 0.2.0

SQLx database adapters for RustAuth.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use rustauth_core::db::{auth_schema, AuthSchemaOptions, DbAdapter, RateLimitStorage};
use rustauth_sqlx::SqliteStores;

#[tokio::main]
async fn main() -> Result<(), rustauth_core::error::RustAuthError> {
    let schema = auth_schema(AuthSchemaOptions {
        rate_limit_storage: RateLimitStorage::Database,
        ..AuthSchemaOptions::default()
    });
    let stores = SqliteStores::connect_with_schema("sqlite://rustauth.db", schema.clone()).await?;

    // Apply schema with `rustauth db migrate` or `adapter.run_migrations` before serving traffic.
    stores.adapter_ref().run_migrations(&schema).await?;
    let _options = stores.apply_to_options(rustauth_core::options::RustAuthOptions::default());
    Ok(())
}