Comments (8)
Thanks for the quick response, @iiian . I think there's a misunderstanding, I want the table names to be plural, so that the sql looks like
select * from users;
. So in combination with--map-table-case snake
, a prismamodel ShoppingCart
gets@@map("shopping_carts")
Whoop, nope I simply miscommunicated. Meant to say somebody named the table plurally, you want to reference it singularly in code, like sane people, via your generated prisma model.
from prisma-case-format.
I don't need to specify arbitrary table names, though I can see how that would be useful. Depending on how you implement pluralizing, the user may need to provide irregular spellings like Person -> people.
from prisma-case-format.
Hey @maxfurman, glad you found it helpful. I totally get where you're coming from, somebody made the table plural, that's weird, you want it to be singular. Probably doable, can it wait til the weekend?
from prisma-case-format.
Thanks for the quick response, @iiian . I think there's a misunderstanding, I want the table names to be plural, so that the sql looks like select * from users;
. So in combination with --map-table-case snake
, a prisma model ShoppingCart
gets @@map("shopping_carts")
from prisma-case-format.
Proposed interface: I'm thinking about --map-table-case=snake,plural
as the interface for supporting this, where plural
is a new optional argument to signal that database targets should be pluralized. Alternatively, if you're in a scenario where you need to surgically target only a number of tables for renaming, the argument input could be extended to declare tablewise overrides to the rule:
--map-table-case=snake|User:users|Group:pigeons
where User:users
specifies that model User
shall have @@map("users")
and Group:pigeons
specifies that model Group
shall have @@map("pigeons")
. The |
in between shall be separators for mapping override instances.
If you don't need the latter extension for tablewise overrides, I'll just add the --map-table-case=snake,plural
flavor for now.
from prisma-case-format.
v1.5.0 has been released and should address this issue.
from prisma-case-format.
Is it possible to go from plural to singular on the field case? For example:
model Users {
id @id @default(autoincrement())
@@map("users")
}
to
model User {
id @id @default(autoincrement())
@@map("users")
}
from prisma-case-format.
Is it possible to go from plural to singular on the field case? For example:
model Users { id @id @default(autoincrement()) @@map("users") }
to
model User { id @id @default(autoincrement()) @@map("users") }
@ebramanti that's a fair request. I've updated w/ v1.6.0
s.t. you can do
prisma-case-format --table-case=pascal,singular
Which will have the effect of performing the specified transformation.
from prisma-case-format.
Related Issues (20)
- `Unsupported` fields are parsed incorrectly HOT 5
- Enums are not mapped HOT 5
- Add a LICENSE file HOT 4
- Ignore Command & Excluding Enums HOT 4
- Any way to keep enums singular when table names are plural? HOT 3
- Broken output for pascal case HOT 4
- New version of package have old content HOT 1
- No @@map created for enums HOT 5
- Possibility to skip some models HOT 23
- Q. How to use this tool ? HOT 8
- Retain @map annotations for fields with distinct DB column names HOT 6
- Add option to ignore pluralize option per field HOT 8
- [Feature request] Obtain default schema location from package.json
- [Feature request] Enable configuration via package.json HOT 1
- Allow programmatic usage of library (example: vscode formatter extension) HOT 2
- Run Prisma's `formatSchema` before AND after the case formatting to automatically add missing relations HOT 2
- MongoDB ID field issue HOT 4
- Invalid `--uses-next-auth` cli option HOT 1
- Config file does not load before `tryGetFileContents` HOT 2
- Camel case not working as expected for fields with numbers
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prisma-case-format.