Omnia ORM
A lightweight object-relational mapper based on sea-query but completely backend agnostic. This crate is intended as a helper for guests using omnia-wasi-sql to assist in query building and mapping return values to business structures.
This crate uses types from omnia-wasi-sql and re-exports Row and DataType for convenience.
It is intended that this crate is used in guest components only.
Quick Start
Define an Entity
use ;
use entity; // Assuming re-exported or used directly
entity!
CRUD Operations
use ;
// Select with filter
let posts = new
.where
.where
.order_by_desc
.limit
.fetch.await?;
// Insert
new
.set
.set
.set
.build?;
// Or insert from an entity
let post = Post ;
from_entity.build?;
// Update
new
.set
.where
.build?;
// Delete
new
.where
.build?;
Joins
use Join;
// Entity with default joins and column aliasing
entity!
// Joins happen automatically
let posts = new
.fetch.await?;
// Or add ad-hoc joins
let posts = new
.join
.fetch.await?;
Filtering
// Basic comparisons
eq
gt
like
in
// Logical combinators
and
or
// Table-qualified (for joins)
table_eq
col_eq
Upserts
Handle INSERT ... ON CONFLICT scenarios using native database syntax (PostgreSQL/SQLite). These are atomic operations.
// Insert or update on conflict - atomic operation
new
.set
.set
.on_conflict
.do_update
.build?;
// Generates: INSERT INTO users (email, name) VALUES ($1, $2)
// ON CONFLICT (email) DO UPDATE SET name = EXCLUDED.name
License
MIT OR Apache-2.0