tokio-rs / toasty

An async ORM for Rust (incubating)
MIT License
1.09k stars 26 forks source link

sharing experience from `loco.rs` #14

Closed jondot closed 1 month ago

jondot commented 1 month ago

Hi @carllerche This is an exciting project coming from tokio. I've been building loco.rs which I hope fills in the "productivity" part for Rust (referring to that section in your blog post). We're using SeaORM, which is stable and feature rich, and serves us well so far.

Here are some things I looked for when I evaluated SeaORM (against Diesel, sqlx-macros, etc.), I hope to offer (not to push) some insight for Toasty:

// let me extend logic onto my fetched entities to keep logic tied to data let user = User.find(..) if user.has_billing() { //... }


* Lifecycle that is ownership-happy. SeaORM DB connection is cheaply cloned and so this allows for a "downward-only" request flow, where end users of the framework don't care (or aren't aware) of any ownership issues or considerations upstream
* Migrations-as-code, additive. If you look around live Rust / Axum / Sqlx etc. codebases you'll see many people use SQL file migrations, which is not the best for this scenario. People choose an ORM and then get screwed over by specifics of a specific-database SQL DDL language, which live in their migrations.
* Auto migration ("syncing" a schema, as well as versioned, additive migrations)

While there are many more bits and pieces (like relationships, lazy loading, etc -- which I'm sure you'll get right as do all ORMs eventually), I think these are the pivotal ones that can really affect an ORM's design.

Hope this help shape Toasty's direction for the better, and good luck!
codegod100 commented 1 month ago

+1 on the ownership issue. Multiple people are running into #13. Consumers of API shouldn't need to worry about your library's lifetimes

Chaoses-Ib commented 1 month ago

Auto migration ("syncing" a schema, as well as versioned, additive migrations)

There are several crates for this thing, maybe Toasty can integrate or reference them: