dorm_sqlite_database 2.0.0-dev.4 copy "dorm_sqlite_database: ^2.0.0-dev.4" to clipboard
dorm_sqlite_database: ^2.0.0-dev.4 copied to clipboard

A SQLite database engine for dORM applications that need local, persistent relational data with typed queries and transactions.

dorm_sqlite_database #

dorm_sqlite_database on pub.flutter-io.cn dorm_sqlite_database pub points dorm_sqlite_database popularity dorm_sqlite_database likes dorm_sqlite_database documentation dORM repository License Dart CI

dorm_sqlite_database adapts dORM repositories to SQLite through the asynchronous sqlite_async API. It accepts an application-owned SqliteDatabase.

Backend and runtime #

The backend is a local SQLite file through sqlite_async and sqlite3. Web applications require the WASM and worker setup documented by sqlite_async.

Install #

dart pub add dorm_framework
dart pub add dorm_sqlite_database
dart pub add sqlite_async
dart pub add dorm_annotations
dart pub add --dev dorm_generator
dart pub add --dev build_runner

sqlite_async uses sqlite3 underneath. Native Dart and Flutter targets are supported; web usage requires the WASM and worker setup documented by sqlite_async.

Create the engine and Dorm facade #

import 'package:dorm_sqlite_database/dorm_sqlite_database.dart';
import 'package:sqlite_async/sqlite_async.dart';

final database = SqliteDatabase(path: '[PLACEHOLDER: database path]');
await database.execute(
  'CREATE TABLE users (id TEXT PRIMARY KEY, name TEXT NOT NULL)',
);

try {
  final engine = Engine(database);
  final dorm = Dorm(engine);
  // Use generated repositories here.
} finally {
  await database.close();
}

The application owns the database and decides when schema or migration SQL is executed. The engine does not create a schema automatically.

Identities, filters, pages, and relationships #

SQLite supports framework filters, ordering, offset pagination, relationships, simple and composite identities, and batches.

Transactions #

final User user = await dorm.users.repository.put(
  Creation.auto(
    dependency: const UserDependency(),
    data: UserData(name: 'Ada'),
  ),
);

final txDorm = TransactionalDorm(engine);
await txDorm.transaction((tx) async {
  await tx.users.repository.push(user.copyWith(name: 'Ada Lovelace'));
});

Streams #

pull and pullAll use sqlite_async table watches and can emit later changes.

Relationships #

The generated relationship API is the same as other engines; the number of SQL reads depends on the relation plan and fallback path.

Schema, errors, and limitations #

Use SQL or sqlite_async migration facilities from the application. This package does not generate schema or migration history. SQLite and sqlite_async errors are propagated without a dORM-specific error hierarchy.

Run an example #

Generate a local project with the showcase CLI. It includes a schema file and the commands needed to run SQLite without a server:

dart pub global activate dorm_example
dorm_example -e sqlite
0
likes
0
points
143
downloads

Publisher

verified publisherenzosantos.dev

Weekly Downloads

A SQLite database engine for dORM applications that need local, persistent relational data with typed queries and transactions.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

dorm_framework, sqlite3, sqlite_async, uuid

More

Packages that depend on dorm_sqlite_database