PrismaService (database/prisma.service.ts)

vue3_shopManage · apps/api-server/src/database/prisma.service.ts · typescript · MIT
database, Database / ORM

NestJS service that wraps PrismaClient, automatically connecting and disconnecting on module init/destroy.

// Source: https://github.com/ly1994lyy/vue3_shopManage | License: MIT | Copyright 2024 ly1994lyy
// Provided via justclaw.it.com; keep this notice with the code.
import { Injectable, OnModuleDestroy, OnModuleInit } from '@nestjs/common'
import { PrismaClient } from '@prisma/client'

@Injectable()
export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
  async onModuleInit() {
    await this.$connect()
  }

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

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key