Conventions & Standards

This page will provide details on configuration recommendations, as well as define some standards for how you should interact with Prisma Util for an adequate developer experience.

Paths & Denoting Paths

Whenever you define a Path object in your configuration file, you are presented with freedom of choice on how you want to represent that specific path. While that is good if you know what you're doing, we've provided some guidelines that will help you keep track of paths and consistency so you don't end up with configuration issues:

Paths that define a file in the same directory as the configuration file should not start with . and should follow this example instead:

./models/user/User.prisma models/user/User.prisma

You shouldn't use paths in upper directories, but follow a downwards hierarchy instead:

../models/user/User.prisma You should instead copy the file to your current folder, or move the working directory one level above. If moving the working directory isn't an alternative, you can follow the next advice and ignore this one, because this problem is fixed if you do so.

Always use constant values instead of defining your paths in 2 places:

prisma-util.config.mjs
// ❌ Don't create paths like this:
export default {
    includeFiles: ["models/post/Post.prisma"],
    // rest of your configuration
    excludeModels: ["models/post/Post.prisma:Comment"]
};
// ✅ Create paths like this:
const PostPrisma = "models/post/Post.prisma";
export default {
    includeFiles: [PostPrisma],
    // rest of your configuration
    excludeModels: [`${PostPrisma}:Comment`]
};
/* 
Bonus points: Use the constant functions from prisma-util/schema-creator
These constant functions can only be used in Prisma Util v2.0.0+.
More information about prisma-util/schema-creator can be found here: 

If you want to configure generators instead, use constantGenerator.
https://prisma-util.gitbook.io/modules/schema-creator
*/
import { constantModel } from "prisma-util/schema-creator";
const PostPrisma = constantModel("models/post/Post.prisma");
export default {
    includeFiles: [PostPrisma],
    // rest of your configuration
    excludeModels: [PostPrisma("Comment")]
};

Last updated