0.4.12 • Published 2 years ago

@arianaprojects/prisma-nestjs-crud-generator v0.4.12

Weekly downloads
-
License
Apache License 2....
Repository
github
Last release
2 years ago

About The Project

Product Name Screen Shot

There are many great Generators available on GitHub for Prisma Schema; however we wanted a fully automatic and complete generator which is compatible with NestJs and we didn't find. So we created this advanced generator.

Of course, no one Generators will serve all projects since your needs may be different. So We'll be adding more in the near future. You may also suggest changes by forking this repo, creating a pull request, or opening an issue. Thanks to all the people who have contributed to expanding this template!

Built With

This project is built on top of Next.js Framework Template, which is fully configured by Our Team at Ariana Company. You need at least the following packages and libraries for this Generator, which we used in our NestJs template.

Getting Started

This section will learn how to use our generator with Prisma and NestJs. We will not show how to install and configure NestJs, and we assume that you know NestJs and Prisma well

Installation

Simply install the Prisma Code Generator

  • npm
    npm i @ariana-germany/prisma-code-generator -D
    yarn add @ariana-germany/prisma-code-generator -D

Configuration

After installation, you should add our configuration to your Prisma.schema File.

generator Prisma_Code_Generator {
  provider = "Prisma_Code_Generator"
  output   = "../gen"
}

Output path is relative to the path of the Prisma.schema File and should be an folder.

WARNING: Generator will overwrite the folders with the same name as models in the output path.

Generation

The Prisma command line interface (CLI) is the primary way to interact with our Generator.

for example:

npx prisma generate

Usage

Now, your CRUD is generated. For using this generated CRUD you should import each of the Module's Model in to your main module. In our case is app.module.ts.

Example

Now, your CRUD is generated. For using this generated CRUD you should import each of the Module's Model in to your main module. In our case is app.module.ts.

Prisma.schema

generator prismaCodeGenerator {
  provider = "prisma-code-generator"
  output   = "../gen"
}


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

}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model User {
  id      Int       @id @default(autoincrement())
  email   String    @unique
  name    String?
  Address Address[]
}

model Address {
  id        Int       @id @default(autoincrement())
  createdAt DateTime  @default(now())
  updatedAt DateTime  @updatedAt
  deletedAt DateTime?
  User      User?     @relation(fields: [userId], references: [id])
  Tax       Tax[]
  axId      Int?
  line1     String
  line2     String
  line3     String
  city      String
  zipcode   String
  userId    Int?
}

model Tax {
  id        Int       @id @default(autoincrement())
  createdAt DateTime  @default(now())
  updatedAt DateTime  @updatedAt
  deletedAt DateTime?
  Address   Address?  @relation(fields: [addressId], references: [id])
  addressId Int?
}

Folder sctructure

📦gen
 ┣ 📂address
 ┃ ┣ 📜address.controller.ts
 ┃ ┣ 📜address.dto.ts
 ┃ ┣ 📜address.entity.ts
 ┃ ┣ 📜address.module.ts
 ┃ ┗ 📜address.service.ts
 ┣ 📂tax
 ┃ ┣ 📜tax.controller.ts
 ┃ ┣ 📜tax.dto.ts
 ┃ ┣ 📜tax.entity.ts
 ┃ ┣ 📜tax.module.ts
 ┃ ┗ 📜tax.service.ts
 ┗ 📂user
 ┃ ┣ 📜user.controller.ts
 ┃ ┣ 📜user.dto.ts
 ┃ ┣ 📜user.entity.ts
 ┃ ┣ 📜user.module.ts
 ┃ ┗ 📜user.service.ts

app.module.ts

@Module({
  imports: [
    ...
    AddressModule,
    TaxModule,
    UserModule,
    ...
  ],
  controllers: [
    ...
  ],
  providers: [
    ...
  ],
})
export class AppModule implements NestModule {
  ...
}

Roadmap

  • initial
  • soft Delete
  • Add Additional Templates w/ Examples
  • Refactoring
  • MySQL
  • MongoDB

See the open issues for a full list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the Apache License Version 2.0 License. See LICENSE.txt for more information.

Contact

Shayan - shayan.fard@arianagermany.com - shayandavarifard@yahoo.com

0.4.9

2 years ago

0.4.8

2 years ago

0.3.17

2 years ago

0.3.16

2 years ago

0.3.15

2 years ago

0.3.14

2 years ago

0.3.13

2 years ago

0.3.20

2 years ago

0.4.10

2 years ago

0.4.11

2 years ago

0.3.22

2 years ago

0.4.12

2 years ago

0.3.21

2 years ago

0.3.19

2 years ago

0.3.18

2 years ago

0.4.5

2 years ago

0.4.4

2 years ago

0.4.7

2 years ago

0.4.6

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.4.3

2 years ago

0.4.2

2 years ago

0.3.12

2 years ago

0.3.11

2 years ago

0.3.10

2 years ago

0.3.9

2 years ago

0.3.8

2 years ago

0.3.7

2 years ago

0.3.6

2 years ago

0.3.5

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.11

2 years ago