Database / ORM Overview
Database Drivers
Archery comes equipped with a revolutionary ORM capable of speaking to several vastly different permanent storage systems using identical Model syntax.
All database queries in Archery fall back to a system default disk, but you can override the storage destination globally via configuration, per model, or even per individual query.
Available Drivers
Archery currently ships with four available database disk drivers:
DatabaseDisk.sqlite: A powerful localized Relational Database system embedded alongside your application binary. Extremely fast for lightweight deployments.DatabaseDisk.pgsql: A traditional PostgreSQL connection driver supporting large-scale enterprise data handling.DatabaseDisk.file: A server-less flat-file driver. Your data is stored natively inside localstorage/json_file_models/JSON documents. Excellent for small apps or cache-like behavior.DatabaseDisk.s3: An architecture-less cloud solution where Archery persists your JSON documents directly into an Amazon S3 Bucket. This allows you to scale indefinitely without ever deploying or managing a heavy SQL server cluster.
Declaring Disks
You can instruct your models to utilize different storage mechanisms across the board extremely easily.
Per Query Overrides
If you wish to mutate or retrieve data from an alternative system for a specific subset of operations, simply pass the disk argument to any ORM command:
// Fetch flights from S3
final oldFlights = await Model.all<Flight>(disk: DatabaseDisk.s3);
for (var flight in oldFlights) {
// Transfer the flight to the local SQLite disk
await flight.save(disk: DatabaseDisk.sqlite);
}
Per Model Overrides
You may have an application where authentication and payments run on a secure Postgres server, but application logging and lightweight chat messages save directly to S3. You can override the target disk as a property on the Model directly:
class ChatMessage extends Model {
// Override the default disk for this specific Model
@override
DatabaseDisk get disk => DatabaseDisk.s3;
String body;
ChatMessage({required this.body});
@override
Map<String, dynamic> toJson() => {'body': body};
}