typeorm-factory
typeorm-factory copied to clipboard
`Factory.attr(_, value)` support value function
Hi.
I am trying to use Faker with Factory.attr
. Currently, the second argument is limited to T[K]
from attr<K extends keyof T>(name: K, value: T[K])
.
Would you please make it support value: T[K] | () => T[K]
?
Hello @ivawzh, you can use the sequence
method to do that:
.sequence('username', (_) => faker.internet.userName());
Hi @RodolfoSilva, thanks for the workaround tips.
Meanwhile imho, it'd still be better to have an intuitive API that uses the right names for the right things. sequence
is normally referred to a sequential number-embedded generator. value
function is better reflecting a stateless attribute value generator.
I agree, something like https://preview.adonisjs.com/guides/database/factories