Overview + installation

Before starting, you need to be authenticated, since the package is hosted within a private npm registry, the authentication steps are described before.

Authentication chevron-right

The EntityModule package is a dynamic NestJS module that simplifies the process of creating CRUD operations for entities using Prisma. It automatically generates the necessary logic for managing database records and allows you to customize the behavior of the CRUD operations with a flexible configuration. This package is designed to work seamlessly with your Prisma models, making it ideal for building efficient and scalable backend applications. To know more about Prisma, you can check the documentation:https://www.prisma.io/docsarrow-up-right

Install the package in your app :

npm i @tradinos/cms-backend-entity nestjs-cls

Basic Setup:

First, you have to import nestjs-cls module, you can find more information about the setup herearrow-up-right, then you need to import Entity CLS plugin as follows:

import { ClsPluginEntity } from '@tradinos/cms-backend-entity';

ClsModule.forRoot({
    // ....
    plugins: [
        new ClsPluginEntity(),
    ],
}),

lastly, you need to import the EntityModule into your NestJS module and provide the necessary configuration.

import { EntityModule } from "@tradinos/cms-backend-entity"

EntityModule.register({
    // Options Here
})   

The register method in the EntityModule accepts an EntityOptions object that allows you to configure the module’s behaviour.

Note that if your ClsModule is not globally porvided you will need to import the ClsModule.forFeature() into the EntityModule

we will talk about each option in the next page ...!

Last updated