1.0.4 • Published 5 months ago

prisma-case-builder v1.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

Prisma CASE Query Builder āš”ļø

A simple and lightweight CASE query builder for Prisma, making raw SQL queries easier and more readable.

šŸš€ Features

āœ… Fluent, chainable API
āœ… Type-safe column suggestions
āœ… Works seamlessly with Prisma

šŸ“¦ Installation

npm install prisma-case-builder

šŸ› ļø Usage

const result = await prisma.user
  .case("role")
  .when({ column: "age", operator: ">=", value: 18 })
  .then("Adult")
  .when({ column: "age", operator: "<", value: 18 })
  .then("Go home! :P")
  .else("Unknown")
  .toExec();

šŸ”§ Setup

To integrate the CASE query builder with Prisma, extend your PrismaClient:

import { PrismaClient } from "@prisma/client";
import { CaseBuilder } from "prisma-case-builder";

export const prisma = new PrismaClient().$extends({
  model: {
    $allModels: {
      case<T>(this: T, field: string) {
        return new CaseBuilder<T>(this, prisma).case(field);
      },
    },
  },
});

šŸ“œ License

MIT


Enjoy using Prisma CASE Query Builder? Give it a ⭐ on GitHub! šŸš€

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago