Introduction
Orbit is an ORM for Rocket.rs apps. It maps MySQL and MariaDB tables to Rust types, and runs queries, transactions and migrations against them. Its names follow Laravel's Eloquent and query builder, so most of it will be familiar to a Laravel developer. Differences from Laravel lists where Orbit departs from Laravel.
What Orbit covers
- Connecting opens a connection pool and checks that the database answers.
- Models map a table to a struct. The
OrbitModelderive writes the mapping. - Queries build
SELECT,INSERT,UPDATE,DELETEandREPLACEstatements. Values are always sent as bound parameters. - Transactions commit when a closure returns
Okand roll back when it returnsError panics. - Errors lists the typed errors, such as unique and foreign key violations, deadlocks and lock wait timeouts.
- Migrations apply and revert folders of SQL, and can import the history of a Diesel project.
- Blocking API is a synchronous version of the same queries, behind the
blockingfeature.
Databases
Orbit works with MySQL and MariaDB. It does not support other databases yet.
Where to start
Add the crate with the steps in Installation, then connect as shown in Connecting.
Orbit