Core Concepts
Arrays
Managing one-to-many relationships and array fields
So far, we have covered basic fields and simple relationships. This section shows how to work with one‑to‑many relationships and arrays.
Defining a one‑to‑many relationship
Wrap the target entity in an array inside @FactoryType.
Generating arrays of related entities
Use .with(amount, path) to opt‑in and specify the number of children.
Nested relationships
Use dot paths to configure nested relations.
Overriding elements
Override fields with .set() using array paths.
Custom key binding (using key and inverseKey) applies to both one‑to‑one (1:1) and one‑to‑many (1:N) relationships.
Generating multiple root instances
Use Factory.many(Type).make(n) to generate multiple roots.