prisma-case-format
prisma-case-format copied to clipboard
[Feature request] Enable configuration via package.json
For node projects and especially for those of us who want to keep the number dotfiles low, it'd be lovely if the config could alternatively be specified in package.json
. As long as Prisma doesn't offer case mapping natively, the existing config key could be used.
Simple approach
Use the same keys as in the .prisma-case-format
file:
{
"prisma": {
"schema": "./path/to/schema.prisma",
"seed": "tsx ./path/to/seed.ts",
"mapCase": {
"default": "table=pascal; mapTable=snake,plural; field=pascal; mapField=snake; enum=pascal; mapEnum=snake",
"override": {
"LegacyThing": "disable"
}
}
}
}
More sophisitcated and DRYer
For the minimalist. This would assume Prisma's as well as DB naming conventions and just specifies the target format…
{
"prisma": {
"schema": "./path/to/schema.prisma",
"seed": "tsx ./path/to/seed.ts",
"mapCase": "snake"
},
}
…and would be equivalent to the following configs:
{
"prisma": {
"mapCase": {
"table": "snake,plural",
"field": "snake",
"enum": "snake"
}
}
}
{
"prisma": {
"mapCase": {
"table": {
"from": "pascal",
"to": "snake",
"inflect": "plural"
},
"field": {
"from": "camel",
"to": "snake"
},
"enum": {
"from": "pascal",
"to": "snake"
}
}
}
}
Hey, @juni0r, this sounds like a great suggestion. Outside contributions and pull requests are always welcome for this project. I probably wouldn't have time to get to this for several months, as it is not under the umbrella of core functionality or bug fixes.
My only suggestion would be to break out a separate "prisma-case-format" section, and mimic the schema of the .prisma-case-format
file. Since this repo isn't directly affiliated with the prisma
team, my opinion is that we should be separating our config bucket(s) from theirs.