Giter Club home page Giter Club logo

vscodeextension-prisma-schema-tool's Introduction

Prisma-Schema-Tool README

This is a tool designed to convert models and fields in your prisma schema that are in snakeCase to camelCase using the prisma schema map attribute

Reason

There might be situations where the columns in your SQL table are written using snake-case. eg user_id

But you might want to use the prisma api to interact with the field using snake case

Example using:-

prisma.findUnique({
    where:{
        userId:${something}
    }
})

Instead of

prisma.findUnique({
    where:{
        user_id:${something}
    }
})

Or

`model country {
  id           String    @id @default(cuid())
  alpha2_code  String    @unique
  alpha3_code  String    @unique
  name         String    @unique
  demonym      String?
  continent_id String
  continent    Continent @relation(fields: [continent_id], references: [id])
  createdAt    DateTime @default(now())
  updatedAt    DateTime @updatedAt
}`

`model Continent {
  id           String    @id @default(cuid())
  name         String    @unique
  countries    Country[]
  createdAt    DateTime @default(now())
  updatedAt    DateTime @updatedAt
}
`


//convert the code above to the one below

`model country {
  id           String    @id @default(cuid())
  alpha2Code   String    @unique @map("alpha2_code")
  alpha3Code   String    @unique @map("alpha3_code")
  name         String    @unique
  demonym      String?
  continentId  String   @map("continent_id")
  continent    Continent @relation(fields: [continentId], references: [id])
  createdAt    DateTime @default(now())
  updatedAt    DateTime @updatedAt
}
`

How to use

  • Right click on the prisma file which must end with the .prisma extension
  • select Prisma Schema Convert menu option
  • The file should be converted by now

You can check out my blog swacblooms for details on this extension

Contact

This repository is currently not up to speed with Prisma's development.

So if you're seeing this now (3rd,APRIL,2021) or sometime in the future, It is actually deprecated. Thank you ๐Ÿ˜…

vscodeextension-prisma-schema-tool's People

Contributors

martineboh avatar sammychinedu2ky avatar

Stargazers

 avatar

Watchers

 avatar  avatar

vscodeextension-prisma-schema-tool's Issues

BUG REPORT

work for 2 words, not working for 3 words.

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.