Skip to content
Discussion options

You must be logged in to vote

Hi, @darr1s. 👋

  1. Prisma generated factories cannot create custom variables.

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
    },
  })
  1. UUIDs are generated as strings, and createdAt fields with @default(now()) are also generated (as mentioned in the original README).

Y…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@darr1s
Comment options

@ktmouk
Comment options

Answer selected by ktmouk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants