StateTransformer<TModel extends OrmEntity> typedef

StateTransformer<TModel extends OrmEntity> = Map<String, Object?> Function(Map<String, Object?> attributes)

Model factories for generating test data and seed records.

Generated model helpers typically expose a factory() method that returns a ModelFactoryBuilder. Use it to configure and build models with predictable data.

// Create an in-memory model instance.
final user = User.factory().make();

// Persist a model (requires a QueryContext).
final saved = await User.factory().create(context: ctx);

// Create multiple records with overrides.
final users = await User.factory()
    .count(3)
    .withField('is_active', true)
    .createMany(context: ctx);

Before using model helpers that hit the database, a connection must be configured.

In most apps, calling DataSource.init() is sufficient because it registers a default data source on ConnectionManager. For custom wiring, call Model.bindConnectionResolver(...).

Signature for state transformation closures.

Implementation

typedef StateTransformer<TModel extends OrmEntity> =
    Map<String, Object?> Function(Map<String, Object?> attributes);