11 releases
new 0.2.1 | Sep 17, 2023 |
---|---|
0.2.0 | Sep 9, 2023 |
0.1.9 | Sep 9, 2023 |
0.1.8 | Aug 1, 2023 |
0.1.4 | Apr 25, 2023 |
#7 in #database-interfaces
335 downloads per month
Used in 2 crates
(via welds)
43KB
1K
SLoC

An async ORM written in rust using the sqlx framework.
Welds
Welds is an async ORM written in rust using the sqlx framework.
Features
- Async for all.
- Support for multiple SQL databases (Mssql, MySql, Postgres, Sqlite)
- Written for ease of development. Features aren't hidden behind traits. Code should be simple to write, and simple to read.
- sqlx always available when you need to drop down to something lower level
Example Setup
#[derive(Debug, sqlx::FromRow, WeldsModel)]
#[welds(db(Postgres))]
//#[welds(db(Postgres, Mssql, Mysql, Sqlite))]
#[welds(schema= "inventory", table = "products")]
#[welds(BelongsTo(seller, super::people::People, "seller_id"))]
pub struct Product {
#[sqlx(rename = "product_id")]
#[welds(primary_key)]
pub id: i32,
pub name: String,
pub seller_id: Option<i32>,
pub description: Option<String>,
pub price: Option<f32>,
}
Example Usage
Basic Select
let url = "postgres://postgres:password@localhost:5432";
let pool = welds::connection::connect_postgres(url).await.unwrap();
let products = Product::where_col(|p| p.price.equal(3.50)).run(&pool).await?;
Basic Filter Across tables
let conn = welds::connection::connect_mssql(url).await.unwrap();
let sellers = Product::where_col(|product| product.price.equal(3.50))
.map_query(|product| product.seller )
.where_col(|seller| seller.name.ilike("%Nessie%") )
.run(&conn).await?;
Create And Update
let conn = welds::connection::connect_sqlite(url).await.unwrap();
let mut cookies = Product::new();
cookies.name = "cookies".to_owned();
// Creates the product cookie
cookies.save.await(&conn)?;
cookies.description = "Yum".to_owned();
// Updates the Cookies
cookies.save.await(&conn)?;
Other Examples
- Basic CRUD
- Mapping Queries / Joining
- Bulk (Create/Update/Delete)
- Select Only Specific Columns
- Checking DB schema matches compiled structs
For more good examples check out the examples repo.
Dependencies
~8–23MB
~390K SLoC