Skip to content

Add "index" dependet overrides for createMany/makeMany #170

@lmeysel

Description

@lmeysel

It would be super helpful if I could createMany or makeMany with e.g. some kind of callback which passes the element number being created. This could easily allow seeding multiple entities with (simple) state differences

// Example 1: Seeding users, where some of them should not be active:
new UserFactory().createMany(10, (index: number) => ({ isActive: Boolean(index % 3) }));

// Example 2: Seeding products, with a "unnatural" order in database:
new ProductFactory().createMany(10, (index: number) => ({ order: 10 - (index % 5) }));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions