\n\n\n
\n- UUIDs are generated as strings, and createdAt fields with @default(now()) are also generated (as mentioned in the original README).
\n
Yes, prisma-factory currently does not support generating default values based on native database type attributes because DMMF, used in prisma-factory, does not support passing native types (ref: prisma/prisma#10252). Therefore, one simple way is to override the id property yourself, as you already described.
\n\n\n\n
\n- No sequence number accessor.
\n
Could you please tell me more about the sequence number accessor? Is it similar to sequences in factory_bot?
","upvoteCount":1,"url":"https://github.com/orgs/factory-js/discussions/28#discussioncomment-9555555"}}}-
Hi there! Thanks for the great repo. I am currently using this in my project and have noticed a few issues:
Given the current options of after + traits, I'm unsure if I should create all the factories. So, I wrote a script to generate base factories with ((id) => uuid()) based on the generated ones. I then use these base factories for my real e2e factories, making the seeders simpler and easier to manage than maintaining 100+ factories for schema models. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi, @darr1s. 👋
It is impossible to add new variables to the defined factory because of TypeScript limitation, but you can create a new factory with the defined factory by using .def, like below: const baseUserFactory = defineUserFactory(db)
const { props, vars } = baseUserFactory.def
export const userFactory = await factory
.define({
props: {
...props,
foo: () => "foo", // add 'foo' prop
},
vars: {
...vars,
bar: () => "bar", // add 'bar' var
},
})
Yes, prisma-factory currently does not support generating default values based on native database type attributes because DMMF, used in prisma-factory, does not support passing native types (ref: prisma/prisma#10252). Therefore, one simple way is to override the id property yourself, as you already described.
Could you please tell me more about the sequence number accessor? Is it similar to sequences in factory_bot? |
Beta Was this translation helpful? Give feedback.
Hi, @darr1s. 👋
It is impossible to add new variables to the defined factory because of TypeScript limitation, but you can create a new factory with the defined factory by using .def, like below:
Y…