Seeder class abstract

The base Seeder class.

Seeders are used to populate your database with initial or test data. Think of it as a way to plant seeds of data into your database.

Creating a Seeder

class UserSeeder extends Seeder {
  @override
  Future<void> run() async {
    await UserFactory().count(50).create();
  }
}

Running Seeders

// Run a single seeder
await UserSeeder().run();

// Run multiple seeders via DatabaseSeeder
class DatabaseSeeder extends Seeder {
  @override
  Future<void> run() async {
    await call([
      UserSeeder(),
      PostSeeder(),
      CommentSeeder(),
    ]);
  }
}

Constructors

Seeder()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

call(List<Seeder> seeders) Future<void>
Call other seeders from within this seeder.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
run() Future<void>
Run the database seeds.
toString() String
A string representation of this object.
inherited

Operators

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