Git Product home page Git Product logo

Comments (8)

iiian avatar iiian commented on July 20, 2024 1

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")

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.

maxfurman avatar maxfurman commented on July 20, 2024 1

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.

iiian avatar iiian commented on July 20, 2024

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.

maxfurman avatar maxfurman commented on July 20, 2024

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.

iiian avatar iiian commented on July 20, 2024

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.

iiian avatar iiian commented on July 20, 2024

v1.5.0 has been released and should address this issue.

from prisma-case-format.

ebramanti avatar ebramanti commented on July 20, 2024

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.

iiian avatar iiian commented on July 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.