UNPKG

@algochad/prisma-core

Version:

A comprehensive NestJS library that provides EF-Core-like operations using Prisma and GraphQL. Features LINQ-style query builders, advanced data manipulation, GraphQL integration with genql, and a unified API for both Prisma and GraphQL operations. Includ

58 lines 1.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PrismaMutationBuilder = void 0; class PrismaMutationBuilder { prismaModel; constructor(prismaModel) { this.prismaModel = prismaModel; } static create(prismaModel) { return new PrismaMutationBuilder(prismaModel); } static createFrom(builder, prismaModel) { return new PrismaMutationBuilder(prismaModel); } async Create(data) { return this.prismaModel.create({ data }); } async CreateMany(data) { return this.prismaModel.createMany({ data }); } async Update(where, data) { return this.prismaModel.update({ where, data }); } async UpdateMany(where, data) { return this.prismaModel.updateMany({ where, data }); } async Delete(where) { return this.prismaModel.delete({ where }); } async DeleteMany(where) { return this.prismaModel.deleteMany({ where }); } async BulkUpsert(records) { const results = []; for (const record of records) { const result = await this.prismaModel.upsert({ where: record.where, create: record.create, update: record.update, }); results.push(result); } return results; } async Transaction(operations) { const results = []; for (const operation of operations) { const result = await operation(this); results.push(result); } return results; } ContextFactory() { return new PrismaMutationBuilder(this.prismaModel); } } exports.PrismaMutationBuilder = PrismaMutationBuilder; //# sourceMappingURL=prisma-mutation-builder.js.map