prisma-next-crud-generator

1.3.0 • Public • Published

Prisma Next CRUD Generator

This generator was bootstraped using create-prisma-generator

Prisma generator that generates CRUD operations based on your models, using Next.js.

Requirements

How to use it?

1. Install the generator

npm i -D prisma-next-crud-generator

2. Add the generator to your Prisma schema and add some models

generator client {
  provider = "prisma-client-js"
}

generator next_crud {
  provider = "prisma-next-crud-generator"
}

model User {
  id        Int      @id @default(autoincrement())
  name      String
  email     String   @unique
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
}

model Product {
  id                    String   @id @default(uuid())
  name                  String
  price                 Float
  reallyLongDescription String?
  createdAt             DateTime @default(now())
  updatedAt             DateTime @updatedAt
}

Note: id, createdAt, updatedAt and deletedAt fields are ignored by the generator in list pages and form inputs. The id is used in the show and edit pages, supporting Int, BigInt and String types.

3. Run npx prisma generate

npx prisma generate

4. Run npm run dev

npm run dev

5. Open http://localhost:3000

And you should see something like this:

Demo of the generated app

That's it! You can now start playing with the generated app.

How to contribute?

  1. Go to the repository and clone it
  2. Enter the generator directory: cd packages/generator
  3. Run npm run dev to start the generator in watch mode
  4. Open another terminal and enter the example directory: cd packages/usage
  5. Run npm run dev to start the example in watch mode
  6. Open http://localhost:3000 and start playing with the example
  7. Make your changes and run npx prisma generate to test your changes
  8. Submit a PR

Package Sidebar

Install

npm i prisma-next-crud-generator

Weekly Downloads

1

Version

1.3.0

License

MIT

Unpacked Size

84.7 kB

Total Files

63

Last publish

Collaborators

  • mbrunos