🌍 Atmosphere
A lightweight sqlx framework for safe and fast postgres interactions
Roadmap
Alpha Release
- Trait System (
Table,Column,Relation..) - Derive Macro (
Schema) - Field Attributes (
#[id], and so on) - Query Generation
- Compile Time Verification
- Attribute Macro (
#[table]) - Attribute Macro (
#[relation]) - Attribute Macro (
#[query])
Beta Release
- Transaction Support
- Custom queries
Stable Release
- Stabilize Traits
- Table Lenses (subsets)
Advanced
- Postgres Composite Types
- Support custom types
- Runtime Inspection
- Generate Graphs
-
validatorsupport
Longterm
- Generate GraphQL Server
Concept
Macros
derive(Schema)
Builds compile time schema of struct and inserts into global database schema. This automatically derives the atmosphere base traits for the following common operations:
Create
Table::insert(&self)&[AsRef<Table>]::insert_all(&self)
Read
Table::find(id: &Id)Table::find_all(ids: &[&Id])
Update
Table::reload(&mut self)Table::update(&self)Table::upsert(&self)
Delete
Table::delete(&mut self)Table::delete_by(id: &Id)Table::delete_all_by(ids: &[&Id])&[AsRef<Table>]::delete_all_by(ids: &[&Id])
#[query]
Enables custom queries on the struct
Advanced Macros
#[table(schema = "public", name = <name>, id = (<a>, <b>))]
configures a table name and schema (schema.table)
id optionally tells atmosphere to use combined primary keys
#[relation(grouped_by = Forest)] and #[fk(Forest)]
enable Tree::by_forest(&forest.id)
#[relation(groups = Tree)] and #[fk(Forest)] (on the Tree)
enable Forest::collect(&self)
#[relation(links = Forest, as = neighbour)] and #[fk(Forest)]
enable Tree::neighbour(&self)
#[virtual(<sql>)]
marks a virtual column
#[lens(Forest)]
data lenses on big structs
#[form(Forest)]
data forms for mutating tables