import { Injectable, OnModuleInit, OnModuleDestroy } from '@nestjs/common';
import { adapterMariaDb } from 'prisma.config.mariadb';
import { PrismaClient } from 'prisma/mariadb/generated/prisma/client/mariadb/client';

@Injectable()
export class PrismaMariaDbService extends PrismaClient implements OnModuleInit, OnModuleDestroy {

    constructor() {
        super({ adapter: adapterMariaDb })
    }

    async onModuleInit() {
        await this.$connect();
    }

    async onModuleDestroy() {
        await this.$disconnect();
    }
}
