npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@arianaprojects/prisma-nestjs-crud-generator

v0.4.12

Published

code generator from Prisma schema

Downloads

105

Readme

About The Project

![Product Name Screen Shot][product-screenshot]

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

  • [x] initial
  • [x] 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 - [email protected] - [email protected]