rok-fluent
Async ORM for Rust built on SQLx, supporting PostgreSQL, MySQL, and SQLite.
Two query styles ship side by side — pick one or use both:
| Style | Feature flag | Inspiration |
|---|---|---|
| Active Record | active |
Laravel Eloquent |
| Typed query DSL | query |
Drizzle ORM |
Installation
[]
= { = "0.4", = ["postgres"] }
Enable both query styles:
= { = "0.4", = ["active", "query", "postgres"] }
Or pull everything in:
= { = "0.4", = ["full"] }
Feature flags
| Flag | Description |
|---|---|
macros (default) |
#[derive(Model)], #[derive(Table)], #[derive(Resource)], #[derive(Seed)] |
active |
Active Record style — ModelQuery, PgModel, MorphTo*, ThroughQuery |
query |
Typed DSL — db::select().from(users::table).where_(users::id.eq(1)) |
postgres |
PostgreSQL via sqlx |
sqlite |
SQLite via sqlx |
mysql |
MySQL via sqlx |
axum |
Tower middleware for Axum |
tracing |
OpenTelemetry-compatible span instrumentation |
metrics |
Prometheus-style query counters |
tenant |
Task-local multi-tenancy |
replica |
Read-replica routing |
migrate |
Schema migration runner |
factory |
Test factory helpers + Faker data generator |
full |
All of the above |
Typed DSL style (query feature)
use db;
// SELECT * FROM "users" WHERE "users"."id" = $1 LIMIT 1
let user: = select
.from
.where_
.
.await?;
// INSERT INTO "users" ("name", "email") VALUES ($1, $2) RETURNING *
let created: User = insert_into
.values
.returning
.
.await?;
// UPDATE "users" SET "name" = $1 WHERE "users"."id" = $2
update
.set
.where_
.execute
.await?;
// DELETE FROM "users" WHERE "users"."id" = $1
delete_from
.where_
.execute
.await?;
Composable WHERE expressions
let expr = email.like
.and
.or;
let rows: = select
.from
.where_
.order_by
.limit
.
.await?;
Active Record style (active + postgres features)
use Model;
// Find by primary key
let post = query.find.await?;
// Scoped query
let recent: = query
.where_eq
.order_by_desc
.limit
.get
.await?;
// Count
let total: i64 = query.count.await?;
// Eager loading (avoids N+1)
let posts_with_author = with_belongs_to.await?;
Migrations (migrate feature)
use ;
use async_trait;
;
new
.migration
.run
.await?;
SqlValue types
| Variant | Rust type | PostgreSQL | SQLite / MySQL |
|---|---|---|---|
Text(String) |
String, &str |
TEXT |
TEXT |
Integer(i64) |
i8–i64, u32, u64 |
BIGINT |
INTEGER |
Float(f64) |
f32, f64 |
FLOAT8 |
REAL |
Bool(bool) |
bool |
BOOLEAN |
BOOLEAN |
Json(Value) |
serde_json::Value |
JSONB |
text blob |
Uuid(Uuid) |
uuid::Uuid |
native UUID |
CHAR(36) |
Null |
Option<T> |
NULL |
NULL |
Health check
if ping.await
License
MIT — see LICENSE.