Before reading this article, make sure you have set up an AdminJS instance using one of the supported Plugins.
Additionally, you should have installed @adminjs/prisma as described in Getting started section.
Following this, register AdminJSPrisma adapter somewhere after your imports:
app.module.ts
AdminJS.registerAdapter({ Database, Resource })
This will allow you to pass Prisma models for AdminJS to load. If we use the Publisher entity that we used as en example earlier, you should import it into app.module.ts and pass it into resources in your adminJsOptions:
app.module.ts
// ... other importsimport { Category } from'./category.entity.js'// ... other codeAdminModule.createAdminAsync({useFactory: () => {// Note: Feel free to contribute to this documentation if you find a Nest-way of// injecting PrismaService into AdminJS moduleconstprisma=newPrismaService()return { adminJsOptions: { rootPath:'/admin', resources: [{ resource: { model:getModelByName('Post'), client: prisma }, options: {}, }], }, } }}),// ... other code
Custom client module
In case your generated client is not under the default path, you can pass clientModule to each resource's configuration:
// other imports// your custom prisma moduleimport PrismaModule from'../prisma/client-prisma/index.js';// ...constprisma=newPrismaModule.PrismaClient();// ...// Notice `clientModule` per resourceconstadmin=newAdminJS({ resources: [{ resource: { model:getModelByName('Post', PrismaModule), client: prisma, clientModule: PrismaModule, }, }],});