:warning: LUNA-ORM is under rapid development, api may change, you should not use it in PRODUCTION env.
For now, just have a basic taste, waiting for the version 1.0
At that time, the api will be stable, and backward compatible will be promised.
LUNA-ORM
LUNA-ORM is an async orm framework based on SQLx. Built with :heart:
- Intuitive : Simple API, the most simple orm in this world.
- Time Saving : Most useful API is implemented by default, no need to waste your life.
- Smooth Transaction : Transaction is almost same as normal.
- Template SQL : You can execute your own sql with no pain.
- Dynamic Parameters : Handle complex dynamic sql with default.
- Truly Asynchronous : Based on SQLx, luna-orm is fully async.
- Error Soundly : Every error has its meaning.
INSTALL
= { = "0.3.5" }
Intuitive
Everything should just works as you want.
Create a database instance.
use *;
use LunaOrmResult;
pub async
Insert an entity
// 1. Declare an Entity, Derive macro Entity, give a TableName
// 2. create an entity.
let entity = HelloEntity ;
// 3. insert it, this is so intuitive, you don't need to warry about anything, it jsut works.
let result = db.insert.await?;
Time Saving
Almost 90% command has been implemented by default, this may saving your time.i
Concept

If you want to insert
// insert an entity if not exists.
async ;
// insert is not exists, and update if already exists.
async ;
// insert an entity if not exists, and return the inserted entity.
async ;
If you want to update
// update one record by primary
async async ;
If you want to delete
// delete one record by primary
async ;
// delete many records by location
async ;
If you want to select
// fetch one entity by primary and select fields by selection
async
Smooth Transaction
let db: = build.await.unwrap.into;
// 1. start a transaction by the simple async api.
let mut trx = db.transaction.await.unwrap;
// 2. just do every thing you want,
// every command is just same as normal.
trx.insert.await?;
trx.select.await?;
trx.delete.await?;
// 3. last thing is just commit, if you forget, trx will rollback by default.
trx.commit.await?;
Template SQL
let template = HelloTemplate ;
// template just works as you want, #{} is the variable
db.execute_by_template.await?;
// if you want to execute paged template,
// you should give a TemplateCountSql, the `as count` is important.
let select_template = HelloSelectTemplate ;
let page = Pagination ;
let result: =
db.search_paged_by_template.await?;
Dynamic Parameters
Truly Asynchronous
Error Sound
MSRV: Minimum Supported Rust Version
1.75.0
LUNA-ORM use async trait.
Safety
This lib uses #![forbid(unsafe_code)]
LICENSE
Apache 2.0