Prisma 2 tool to sort schema models, enums, generators and datasources
Full docs can be found here: click here
Using npm:
$ npm install prisma-schema-sorter
Using yarn:
$ yarn add prisma-schema-sorter
You can use the library in multiple ways as described below.
With the CLI, you get the same functionality but with greater flexibility. You could run the command as a one-off every now and then from the terminal like this:
$ npx prisma-schema-sorter sort --schema="./prisma/schema.prisma"
You could also keep the command as an npm script to run it as part of your workflow:
{
"scripts": {
"sort-schema": "npx prisma-schema-sorter sort --schema='./prisma/schema.prisma'"
}
}
Or even without the npx
prefix:
{
"scripts": {
"sort-schema": "prisma-schema-sorter sort --schema='./prisma/schema.prisma'"
}
}
import { sortPrismaSchema } from 'prisma-schema-sorter';
await sortPrismaSchema('./prisma/schema.prisma');
// => Success
var sortPrismaSchema = require('prisma-schema-sorter').sortPrismaSchema;
sortPrismaSchema().then();
// => Success
Generated using TypeDoc