Toasty, an Async ORM for Rust
Toasty is a new asynchronous ORM for Rust, supporting SQL and NoSQL databases. It focuses on ease of use, allowing users to define data models and generate Rust code, inviting feedback for improvement.
Read original articleToasty is a new asynchronous Object-Relational Mapping (ORM) tool for the Rust programming language, designed to simplify database interactions. Currently in its early development phase, Toasty supports both SQL and NoSQL databases, including Sqlite and DynamoDB, with plans to add Cassandra soon. The tool is not yet available on crates.io and is considered a preview version, inviting user feedback for further development. Users begin by defining their data model in a schema file, which Toasty then uses to generate the necessary Rust code. The focus of Toasty is on ease of use, addressing a gap in Rust's ecosystem where existing ORM libraries often prioritize performance over usability. The generated code aims to minimize complexity, avoiding excessive use of Rust's traits and lifetimes, and opting for explicit code generation rather than procedural macros to enhance readability and discoverability. While Toasty does not abstract the differences between SQL and NoSQL databases, it provides a standard feature set for basic operations and allows for database-specific optimizations. The developer encourages users to experiment with Toasty and provide feedback, with the goal of preparing it for real-world applications by the end of next year.
- Toasty is an asynchronous ORM for Rust, currently in early development.
- It supports both SQL and NoSQL databases, including Sqlite and DynamoDB.
- The tool emphasizes ease of use over performance, addressing gaps in existing Rust ORM libraries.
- Users define data models in schema files, and Toasty generates corresponding Rust code.
- Feedback from users is encouraged to refine the API and prepare for real-world use.
Related
Taking the Drizzle Challenge
Rado is a rewritten Typescript query builder that offers immutable queries, simpler typing, and universal database support, targeting users seeking a lightweight alternative to Drizzle ORM, despite limited documentation.
Show HN: SlateDB – An embedded storage engine built on object storage
SlateDB is an embedded storage engine for object storage systems, featuring batch writes and asynchronous operations. It is in early development, with basic functionalities and an open-source Apache 2.0 license.
BuffDB is a Rust library to simplify multi-plexing on edge devices
BuffDB is a lightweight, high-performance persistence layer for gRPC, developed in Rust. It supports SQLite, DuckDB, and RocksDB, and is ideal for offline data access applications.
Build a quick Local code intelligence using Ollama with Rust
Bosun developed Swiftide, a Rust-based tool for efficient code indexing and querying, utilizing Qdrant and FastEmbed. It enhances performance with OpenTelemetry, integrating various language models for improved response times.
My free book "Rust Projects – Write a Redis Clone" is out
The book by Leonardo Giordani teaches building a Redis-like database using Rust and Tokio, covering essential programming concepts and advanced features, with a 60-day money-back guarantee for purchases.
- Many users find the syntax and method naming confusing, suggesting clearer differentiation for property access.
- Some commenters express skepticism about the effectiveness of ORMs in general, citing issues like the n+1 query problem.
- There are comparisons to existing ORMs like Diesel and SeaORM, with some users preferring these established options.
- Several users question the need for a custom schema definition file, advocating for defining models directly in Rust.
- Overall, there is a divide between those excited about the potential of Toasty and those who prefer traditional SQL approaches.
[1]: https://diesel.rs/
Sooner or later we always hit the n+1 query problem which could only be resolved by a query builder or just plain old sql.
It always was a mess and these days I can't be bothered to try it even anymore because it has cost me a lot of hours and money.
> The common wisdom is to maximize productivity when performance is less critical. I agree with this position. When building a web application, performance is a secondary concern to productivity. So why are teams adopting Rust more often where performance is less critical? It is because once you learn Rust, you can be very productive.
> Productivity is complex and multifaceted. We can all agree that Rust's edit-compile-test cycle could be quicker. This friction is countered by fewer bugs, production issues, and a robust long-term maintenance story (Rust's borrow checker tends to incentivize more maintainable code). Additionally, because Rust can work well for many use cases, whether infrastructure-level server cases, higher-level web applications, or even in the client (browser via WASM and iOS, MacOS, Windows, etc. natively), Rust has an excellent code-reuse story. Internal libraries can be written once and reused in all of these contexts.
> So, while Rust might not be the most productive programming language for prototyping, it is very competitive for projects that will be around for years.
As time passes, the more I feel a minority in adoring rust, while detesting Async. I have attempted it a number of times, but it seems incompatible with my brain's idea of structure. Not asynchronous or concurrent programming, but Async/Await in rust. It appears that most of the networking libraries have committed to this path, and embedded it moving in its direction.
I bring this up because a main reason for my distaste is Async's incompatibility with non-Async. I also bring this up because lack of a Django or SQLAlchemy-style ORM is one reason I continue to write web applications in Python.
Creating your own file format is always difficult. Now, you have to come up with syntax highlighting, refactoring support, go to definition, etc. When I prototype, I tend to rename a lot of my columns and move them around. That is when robust refactoring support, which the language's own LSP already provides, is beneficial, and this approach throws them all away.
Ideally I would use something akin to Go Jet.
Great to see some development in this for Rust, perhaps after it becomes stable I may even switch my SaaS to it.
In my experience, Dynamo and other NoSQL systems are really expressive and powerful when you take the plunge and make your own ORM. That’s because the model of nosql can often play much nicer with somewhat unique structures like
- single table patterns - fully denormalized or graph style structures - compound sort keys (e.g. category prefixed)
Because of that, I would personally recommend developing your own ORM layer, despite the initial cost
I'm not a rust person so I might just be exposing my ignorance here, just wanted to provide feedback since it's on early development.
It reminds me of Prisma and yet, it's all Rust. Also good to see that async is the focus point of the API so the usage feels ergonomic.
Still to me they all suck and nothing beats SQLx
AI writes amazing SQL, modern SQL databases are incredible and the best way to get the most out of your DB is write SQL.
Invest your learning budget in SQL, not in some random developers abstraction.
Related
Taking the Drizzle Challenge
Rado is a rewritten Typescript query builder that offers immutable queries, simpler typing, and universal database support, targeting users seeking a lightweight alternative to Drizzle ORM, despite limited documentation.
Show HN: SlateDB – An embedded storage engine built on object storage
SlateDB is an embedded storage engine for object storage systems, featuring batch writes and asynchronous operations. It is in early development, with basic functionalities and an open-source Apache 2.0 license.
BuffDB is a Rust library to simplify multi-plexing on edge devices
BuffDB is a lightweight, high-performance persistence layer for gRPC, developed in Rust. It supports SQLite, DuckDB, and RocksDB, and is ideal for offline data access applications.
Build a quick Local code intelligence using Ollama with Rust
Bosun developed Swiftide, a Rust-based tool for efficient code indexing and querying, utilizing Qdrant and FastEmbed. It enhances performance with OpenTelemetry, integrating various language models for improved response times.
My free book "Rust Projects – Write a Redis Clone" is out
The book by Leonardo Giordani teaches building a Redis-like database using Rust and Tokio, covering essential programming concepts and advanced features, with a 60-day money-back guarantee for purchases.