DatabaseSeeder class abstract

Base class for database seeders that work with OrmConnection

This is the recommended base class for test seeders.

Example:

class UserSeeder extends DatabaseSeeder {
  UserSeeder(super.connection);

  @override
  Future<void> run() async {
    await seed<User>([
      {'name': 'John Doe', 'email': 'john@example.com'},
      {'name': 'Jane Smith', 'email': 'jane@example.com'},
    ]);
  }
}

Constructors

DatabaseSeeder(OrmConnection connection)

Properties

connection → OrmConnection
final
eventBus ↔ EventBus?
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

attachEventBus(EventBus bus) → void
Attach an event bus so nested seeders share the same emitter.
call(List<DatabaseSeeder Function(OrmConnection)> factories) Future<void>
Call other seeders
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
run() Future<void>
Run the seeder
seed<TModel extends Model<TModel>>(List<Map<String, dynamic>> records) Future<List<TModel>>
Seed multiple records for a given model type
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited