import { PrismaClient } from '@prisma/client' ; import Logger from 'js-logger' ; import { Provider , ProviderTypes } from '../lib/structures/Provider' ; export class PrismaIOProvider extends Provider { client : PrismaClient ; type : ProviderTypes ; constructor ( options ? ) { super ( ) ; this . type = 'prismaio' ; this . client = new PrismaClient ( options ) ; } async init ( ) { Logger . debug ( 'PrismaIO initializated!' ) ; this . emit ( 'connected' , this . client ) ; return ; } async insert ( model , options ) { const data = await this . client [ model ] . create ( options ) ; return data ; } async get ( model , options ) { const data = await this . client [ model ] . findUnique ( options ) ; return data ; } async getMany ( model , options ) { const data = await this . client [ model ] . findMany ( options ) ; return data ; } async update ( model , options ) { const data = await this . client [ model ] . update ( options ) ; return data ; } async delete ( model , options ) { const data = await this . client [ model ] . delete ( options ) ; return data ; } }