Repository navigation
Diwan Database 0.1.0
Diwan Database 0.1.0
The first release of Diwan Database: Laravel's database layer (illuminate/database), ported by
hand to Java 17 and Android. If you know Laravel's query builder, migrations and Eloquent, you
already know most of the API.
Install
implementation("org.aristonis:diwan-database:0.1.0")
implementation("org.aristonis:diwan-database-sqlite:0.1.0") // or -pgsql
implementation("org.aristonis:diwan-database-eloquent:0.1.0") // models, optional
implementation("org.aristonis:diwan-database-android:0.1.0") // Android driver, optionalJava 17 or later, or Android 9 (API 28) or later. SQLite and PostgreSQL. No runtime dependencies.
What's in it
- Connections and transactions: nested transactions with savepoints, automatic retry on
deadlocks, pretend mode, a database manager driven by configuration, and a JDBC adapter that nests
inside a Spring transaction. - Query builder: Laravel's method names for reads, writes, joins, subqueries, unions, upsert,
row locks, chunking, streaming cursors and three kinds of pagination. - Schema builder: every common column type, indexes, foreign keys, checks and
change(). On
SQLite, changes run as a table rebuild that keeps your rows. - Migrations: a migrator with batches, rollback, status, a PostgreSQL migration lock and
optional checksums that stop a run when a migration was edited after it ran. - Models: casts, accessors, events and observers, scopes and soft deletes. No reflection, so
it works with R8 on Android. - Relations: one-to-one, one-to-many, many-to-many with pivot writes (
attach,sync,
toggle), through, polymorphic and one-of-many relations, with eager loading, existence filters
and aggregates. - Seeding and events: seeders, and listeners for queries, transactions, migrations and models.
Built to be safe
- Every value is sent as a parameter. Error messages hide your values by default.
- Strict transactions: a call that would run outside your transaction is refused, not run.
- Bad data fails loudly: a stored value that does not fit its cast throws, where Laravel reads
null,0ortrue.
Know before you start
upsertneeds SQLite 3.24 (Android API 30 and later).- Open every cursor in try-with-resources. A cursor that is not closed keeps its connection.
Links
- Documentation: https://aristonis.org/open-source/diwan-database/docs/main/home
- Differences from Laravel: https://aristonis.org/open-source/diwan-database/docs/main/differences-from-laravel
- Full changelog: CHANGELOG.md
- Report a security problem privately: SECURITY.md