REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 4.56 KB
Close
/proc/thread-self/root/home/byroehnu/.trash/node_modules11/@adminjs/prisma/README.md
Text
Base64
## adminjs-prisma This is an official [AdminJS](https://github.com/SoftwareBrothers/adminjs) adapter which integrates [Prisma](https://prisma.io/) into AdminJS. ### Installation - yarn: `yarn add @adminjs/prisma` - npm: `npm install @adminjs/prisma` ## Usage The plugin can be registered using standard `AdminJS.registerAdapter` method. ```typescript import { Database, Resource } from '@adminjs/prisma' import AdminJS from 'adminjs' AdminJS.registerAdapter({ Database, Resource }) ``` ## Example (Basic) Whole code can be found in `example-app` directory in the repository. ```typescript import express from 'express' import AdminJS from 'adminjs' import AdminJSExpress from '@adminjs/express' import { Database, Resource, getModelByName } from '@adminjs/prisma' import { PrismaClient } from '@prisma/client' import { DMMFClass } from '@prisma/client/runtime' const PORT = process.env.port || 3000 const prisma = new PrismaClient() AdminJS.registerAdapter({ Database, Resource }) const run = async () => { const app = express() const admin = new AdminJS({ resources: [{ resource: { model: getModelByName('Post'), client: prisma }, options: {}, }, { resource: { model: getModelByName('Profile'), client: prisma }, options: {}, }, { resource: { model: getModelByName('Publisher'), client: prisma }, options: {}, }], }) const router = AdminJSExpress.buildRouter(admin) app.use(admin.options.rootPath, router) app.listen(PORT, () => { console.log(`Example app listening at http://localhost:${PORT}`) }) } run() .finally(async () => { await prisma.$disconnect() }) ``` ## Example (Custom Client Output Path) If you defined a custom client output path in your Prisma's schema, for example: ```prisma generator client { provider = "prisma-client-js" output = "./client-prisma" } ``` You must: * import your custom Prisma client * provide it to each resource which uses that Prisma client *Example*: ```typescript // other imports import PrismaModule from '../prisma/client-prisma/index.js'; // ... const prisma = new PrismaModule.PrismaClient(); // ... // Notice `clientModule` per resource const admin = new AdminJS({ resources: [{ resource: { model: getModelByName('Post', PrismaModule), client: prisma, clientModule: PrismaModule }, options: { properties: { someJson: { type: 'mixed', isArray: true }, 'someJson.number': { type: 'number' }, 'someJson.string': { type: 'string' }, 'someJson.boolean': { type: 'boolean' }, 'someJson.date': { type: 'datetime' }, }, }, }, { resource: { model: getModelByName('Profile', PrismaModule), client: prisma, clientModule: PrismaModule }, options: {}, }, { resource: { model: getModelByName('Publisher', PrismaModule), client: prisma, clientModule: PrismaModule }, options: {}, }], }); // ... ``` ## ManyToOne / ManyToMany These relationships are currently not supported by default. You can manage them using custom actions and components. ## Pull request Before you make a PR make sure all tests pass and your code won't cause linter errors. You can do this by running: ``` yarn lint yarn test ``` Make sure you have an `.env` file with `DATABASE_URL` specified. ## Running example app with local code modifications MySQL database is required. You can use the database from `adminjs-example-app`: https://github.com/SoftwareBrothers/adminjs-example-app/blob/master/docker-compose.yaml#L24 ``` $ yarn $ yarn build # after making changes or run "yarn dev" and open a new terminal for next command $ yarn link $ cd example-app $ yarn $ npx prisma generate $ npx prisma migrate dev ``` Now copy `example-app/node_modules/.prisma` folder into `node_modules/.prisma`. This is required because installing library dependencies detects a different Prisma schema in test folder. Continue in `example-app` folder: ``` $ yarn link "@adminjs/prisma" $ yarn build $ yarn start ``` The app should start at port 3000. ## License AdminJS is copyrighted © 2023 rst.software. It is a free software, and may be redistributed under the terms specified in the [LICENSE](LICENSE.md) file. ## About rst.software <img src="https://pbs.twimg.com/profile_images/1367119173604810752/dKVlj1YY_400x400.jpg" width=150> We’re an open, friendly team that helps clients from all over the world to transform their businesses and create astonishing products. * We are available for [hire](https://www.rst.software/estimate-your-project). * If you want to work for us - check out the [career page](https://www.rst.software/join-us).
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 2 × Files: 10
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
.github
DIR
-
drwxr-xr-x
2026-02-28 00:29:02
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
lib
DIR
-
drwxr-xr-x
2026-02-28 00:29:00
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
.eslintrc.cjs
1.13 KB
lrw-r--r--
2026-02-28 00:27:08
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
.prettierrc.json
108 B
lrw-r--r--
2026-02-28 00:28:26
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
.releaserc
425 B
lrw-r--r--
2026-02-28 00:26:44
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
commitlint.config.cjs
78 B
lrw-r--r--
2026-02-28 00:27:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
jest.json
596 B
lrw-r--r--
2026-02-28 00:28:26
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
LICENSE
1.03 KB
lrw-r--r--
2026-02-28 00:26:58
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
package.json
2.23 KB
lrw-r--r--
2026-02-28 00:28:28
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
README.md
4.56 KB
lrw-r--r--
2026-02-28 00:28:50
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
tsconfig.json
581 B
lrw-r--r--
2026-02-28 00:28:30
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
tsconfig.test.json
97 B
lrw-r--r--
2026-02-28 00:28:32
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).