
🌍 Atmosphere
A lightweight sql framework for sustainable database reliant systems
Overview
Atmosphere is a lightweight SQL framework designed for sustainable, database-reliant systems. It leverages Rust's powerful type and macro systems to derive SQL schemas from your rust struct definitions into an advanced trait system.
Key Features
- SQL schema derivation from Rust structs.
- Advanced trait system for query generation.
- Automated database code testing with
atmosphere::testing - ORM-like CRUD traits.
- Code reusability across API layers using generics.
- Compile-time introspection for type-safe schema generation.
Quickstart
use *;
async
Atmosphere introspects the User and Post structs at compile time and
generates const available type information about the schema into the Table
trait.
Roadmap
Alpha Release
- Advanced SQL Trait System (
Table,Column,Relation..) - Derive Macro (
Schema) - SQL Field Attributes (
#[sql(pk)],#[sql(fk -> Model)]and so on) - SQL Query Generation
- Automated Integration Testing
- Attribute Macro (
#[table])
Beta Release
- Transaction Support
- Getting Database Agnostic
- Hook into query execution using
atmosphere::hooks - Errors using
miette - Combined Primary and Foreign Keys
Stable Release
- Postgres Composite Types
- Support Custom Types
- Runtime Inspection
- Provide Application Utils
- Stabilize Traits
- Stabilize Query Generation
- Table Lenses (subsets / views)
-
validatorsupport - Auto Timestamping
Advanced
- Virtual Columns using (
#[virtual = "<sql>"]) - Soft Delete Support
- Attribute Macro (
#[query]) - Custom queries
Longterm
- Generate GraphQL + HTTP Servers?
- Generate Graphs
Functionalities
Given a struct Model that derives its atmosphere schema using
#[derive(Schema)] and #[table]:
use *;
Atmosphere is able to derive and generate the following queries:
CRUD
atmosphere::Create
Model::create
atmosphere::Read
Model::findModel::find_allModel::reload
atmosphere::Update
Model::updateModel::save
atmosphere::Delete
Model::deleteModel::delete_by
Field Queries
Each struct field that is marked with #[sql(unique)] becomes queryable.
In the above example b was marked as unique so atmosphere implements:
Model::find_by_bModel::delete_by_b
Relationships & Inter-Table Queries
Given that a model contains fields are marked as a foreign key / point to
another atmosphere::Table atmosphere – for example:
Atmosphere is able to generate utility queries to move across Table boundaries:
Model::submodelsModel::delete_submodelsSubmodel::modelSubmodel::find_by_modelSubmodel::delete_by_model
Note that the function names contain
modelandsubmodel– they are derived from the respective struct names.
Contribution
We welcome contributions! Please see our contribution guidelines for more details.
License
Atmosphere is licensed under Apache 2.0.