Prisma Plugin
Options

Generator Options

The Prisma generator for FactoryJS has the following options:

generator factory {
  provider           = "prisma-factory"
  output             = "./generated"
  randModule         = "./rand"
  prismaClientModule = "./dist"
}

output

Specifies the output directory for the generated factories. The default is ./generated.

randModule

Specifies the module used to generate random values based on field types. The default is @factory-js/prisma-factory. If you want to customize the existing behavior, you can use the spread syntax to partially modify the original behavior.

In the example below, the random value for the String type is changed to use UUIDs.

rands.ts
import { rands as originalRands } from "@factory-js/prisma-factory";
import { faker } from "@faker-js/faker";
 
export const rands = {
  ...originalRands,
  String: () => faker.string.uuid(),
};

You can check the default random value generation methods in rands.ts (opens in a new tab).

To use the custom module created above, specify the relative path in the randModule option.

prisma.schema
generator factory {
  provider   = "prisma-factory"
  randModule = "./rands"
}

This way, the default value for properties with a String type field will be a UUID.

prismaClientModule

Specifies the import path for PrismaClient. The default is @prisma/client. If you have changed the output location of PrismaClient using the output (opens in a new tab) option, you need to use this option to specify the new import path.