relational_orm 0.1.2 copy "relational_orm: ^0.1.2" to clipboard
relational_orm: ^0.1.2 copied to clipboard

A lightweight Active Record ORM for Dart and Flutter with relations, eager loading, polymorphic relationships, and support for custom database adapters.

example/main.dart

import 'package:relational_orm/relational_orm.dart';

import 'database_adapter.dart';
import 'database.dart';
import 'model/user.dart';
import 'model/post.dart';

Future<void> main() async {
  // Create test database
  final testDb = TestDatabase();
  await testDb.open();

  // Configure ORM
  RelationalOrmConfig.configure(
    database: DatabaseAdapter(testDb.db),
  );

  // Create user
  final user = User(
    name: 'John Doe',
    email: 'john@example.com',
  );

  await user.save();

  // Create post
  await Post(
    userId: user.id,
    title: 'Hello Relational ORM',
  ).save();

  // Query users with relations
  final users = await User()
      .query()
      .include(['posts'])
      .get();

  for (final user in users) {
    print('User: ${user.name}');

    for (final post in user.posts) {
      print('  Post: ${post.title}');
    }
  }

  await testDb.close();
}
2
likes
160
points
81
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A lightweight Active Record ORM for Dart and Flutter with relations, eager loading, polymorphic relationships, and support for custom database adapters.

Repository (GitHub)
View/report issues

Topics

#orm #database #query-builder #flutter #sqlite

License

Apache-2.0 (license)

Dependencies

freezed_annotation, intl, json_annotation, uuid

More

Packages that depend on relational_orm