Class DatabaseModule

DatabaseModule is a global NestJS module that provides a Prisma service for working with the database. It can be imported in any module to access the PrismaService and interact with the database.

Remarks

This module is designed to be used globally to ensure that the same instance of PrismaService is shared across the entire application, providing a single connection to the database.

Hierarchy

  • DatabaseModule

Constructors

Methods

Constructors

Methods

  • Create a dynamic module for the DatabaseModule with optional Prisma client options. This method is used to configure the PrismaService with custom options, if needed.

    Parameters

    • Optional options: PrismaClientOptions

      Optional configuration options for the Prisma client.

    Returns DynamicModule

    • A dynamic module containing the PrismaService provider.

    Example

    // Import the DatabaseModule and provide custom options for the Prisma client.
    DatabaseModule.forRoot({
    datasources: {
    db: {
    url: 'DATABASE_URL',
    },
    },
    models: {
    User: {
    // Custom model configuration
    },
    },
    });

Generated using TypeDoc