26 releases
0.4.0-alpha.2 | Oct 4, 2024 |
---|---|
0.3.0-alpha.3 | Aug 30, 2024 |
0.2.1 | Jan 30, 2023 |
0.2.0-beta.9 | Dec 25, 2022 |
0.0.0 | May 10, 2022 |
#488 in Database interfaces
115 downloads per month
230KB
2.5K
SLoC
Teil, basic data mapper for Postgres/Sqlite
Teil (pronounced /tail/)is a library that intends to make a connection to postgres (or sqlite) as simple as possible (with the limitations that this implies). Teil means part, portion or piece in german.
use teil::{Teil, fields::Serial};
#[derive(Teil, Debug)]
struct Account {
#[teil(auto, primary_key)]
id: Serial,
#[teil(unique)]
owner: String,
#[teil(rename = "account_balance")]
balance: f64
}
teil::config()
.user("example")
.password("password")
.dbname("example_db")
.host("127.0.0.1")
.port(5432)
.set().unwrap();
teil::create!(Account);
(Account {id: Serial::new(), owner: "Carlos".into(), balance: 420.00}).save().await.unwrap();
let account = Account::retrieve(1).await.unwrap();
println!("{:?}", account);
teil::destroy!(Account);
Features available for this crate
sync
: Enables the use of the sync version of the library (that is, theSyncTeil
andSyncFilter
traits and derive macros)iter
: Allows a transaction-based multiple-save function to be used (seesave_iter
and the sync version ofsave_iter
)chrono
: Allows some chrono fields to be used as fields in aTeil
-deriving structure. SeeTeilField
andSyncTeilField
for more information.partial
: Enables partial updating fields of a row in the database. See theupdate
method for more information (or the sync version,update
)uuid
: Allows the use of the Uuid type with the derive macrosserde
: Implements Serialize and Deserialize for the Serial, BigSerial, SmallSerial, and theUpdate
associated type when using the derive macrosfs
: Enables some filesystem manager functionality in order to store files locally with the help of a metadata table.
Dependencies
~8–22MB
~318K SLoC