This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable, OnModuleDestroy, OnModuleInit } from '@nestjs/common' | |
import { PrismaClient } from '@prisma/client' | |
import { faker } from '@faker-js/faker' | |
@Injectable() | |
export class DatabaseService | |
extends PrismaClient | |
implements OnModuleInit, OnModuleDestroy | |
{ | |
constructor() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
constructor() { | |
super() | |
const ext = Prisma.defineExtension((client) => | |
client.$extends({ | |
name: 'webinarAfterCreate', | |
query: { | |
webinar: { | |
async create({ args, query }) { | |
console.log('webinarAfterCreate', args) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable, OnModuleDestroy, OnModuleInit, Type } from '@nestjs/common'; | |
import { PrismaClient, Prisma } from '@prisma/client'; | |
const existsExtension = Prisma.defineExtension({ | |
name: 'exists-extension', | |
model: { | |
$allModels: { | |
async exists<T>(this: T, where: Prisma.Args<T, 'findFirst'>['where']): Promise<boolean> { | |
const context = Prisma.getExtensionContext(this); | |
const result = await (context as any).findFirst({ where }); |
OlderNewer