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

prisma-repository-generator

v3.2.1

Published

A utility to generate repository classes based on Prisma models.

Downloads

75,470

Readme

🚀 Prisma Repository Generator

🌟 Description

Prisma Repository Generator is a powerful utility designed to automate the creation of repository files based on your Prisma models. It eliminates repetitive boilerplate code by generating common CRUD operations for database interactions, which improves consistency, scalability, and maintainability across your applications.

Instead of manually generating repetitive database logic code for each Prisma model, it generates reusable repository classes with standard methods. Developers can focus on application development instead of tedious CRUD generation.

📌 NOTE
This generator currently only works with TypeScript. Support for additional languages ​​may be added in the future.

📥 Prerequisites

Before using the Prisma Repository Generator, make sure you have the necessary dependencies and tools ready:

1. Install Prisma Client

npm install @prisma/client

2. Install Prisma Repository Generator

npm install prisma-repository-generator

⚙️ Setup Instructions

Follow the steps below to set up Prisma and generate repositories:

1. Set Up Prisma Database Schema

Make sure you define the Prisma schema in prisma/schema.prisma. Here is an example of a schema you can use:

model User {
  id    Int    @id @default(autoincrement())
  name  String
  email String @unique
}

model Post {
  id      Int    @id @default(autoincrement())
  title   String
  content String
  userId  Int
}

2. Run Migrations

After defining your schema, apply it to the database using the following command:

npx prisma migrate dev --name init

This will create the necessary database structure.

⚠️ IMPORTANT
Make sure you run migrations (npx prisma migrate dev --name init) before using the repository generator to avoid runtime issues.

3. Generate Repositories

Import and execute the repository generator with the following:

import { generateRepositories } from 'prisma-repository-generator';

generateRepositories().catch((err) => {
    console.error("Error generating repositories:", err.message);
});

This will create repository files based on your Prisma models.

✂️ Shortcut

To simplify and speed up the repository generation process without needing to write extra code, use the following command directly from your terminal:

npx prisma-repository-generator

This command will automatically run the Prisma Repository Generator. You don’t need to import or write additional code in your project. Just run this command in your project directory after ensuring Prisma is set up correctly.

⚠️ IMPORTANT
Make sure you run migrations (npx prisma migrate dev --name init) before using this shortcut to avoid to avoid runtime issues.

✅Features

  • [x] findUnique : Retrieve a single record by unique identifier.
  • [x] findUniqueOrThrow : Retrieve a single record or throw an error if it doesn't exist.
  • [x] findFirst : Fetch the first matching record with optional filtering and sorting.
  • [x] findFirstOrThrow : Same as findFirst, but throws an error if no record is found.
  • [x] findMany : Fetch multiple records with filtering, pagination, and cursor support.
  • [x] create : Insert a single record.
  • [x] update : Update a record by unique identifier.
  • [x] upsert : Insert or update a record based on a unique condition.
  • [x] delete : Delete a single record by unique identifier.
  • [x] createMany : Insert multiple records at once.
  • [x] updateMany : Update multiple records with specific conditions.
  • [x] deleteMany : Delete multiple records based on optional filtering.
  • [x] count : Count records with optional filtering.
  • [x] aggregate : Perform aggregation queries.

💰Support Me

PayPal Saweria Trakteer