JSPM

adminjs-drizzle

0.1.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 13
  • Score
    100M100P100Q59316F
  • License MIT

Drizzle ORM adapter for AdminJS

Package Exports

  • adminjs-drizzle/mysql
  • adminjs-drizzle/pg
  • adminjs-drizzle/sqlite

Readme

adminjs-drizzle

This is an AdminJS adapter which integrates Drizzle ORM into AdminJS.

Installation

pnpm

$ pnpm add adminjs-drizzle

yarn

$ yarn add adminjs-drizzle

npm

$ npm i adminjs-drizzle

Usage

The plugin can be registered using the standard AdminJS.registerAdapter method. It provides specialized adapters for PostgreSQL, MySQL and SQLite.

import AdminJS from 'adminjs';
import { Database, Resource } from 'adminjs-drizzle/pg';
// import { Database, Resource } from 'adminjs-drizzle/mysql';
// import { Database, Resource } from 'adminjs-drizzle/sqlite';
import { drizzle } from 'drizzle-orm/pglite';
import { users } from './schema/users.js';

async function setupAdminJs() {
    // For available database connections please refer to the Drizzle ORM documentation.
    // Here we just use PGLite in memory.
    const db = drizzle();

    AdminJS.registerAdapter({ Database, Resource });

    // You can instantiate AdminJS either by specifying all resources separately:
    const adminJs = new AdminJS({
        resources: [{ resource: { table: users, db }, options: {} }],
    });

    // Or by passing the database and schema into `databases` property.
    const adminJs = new AdminJS({
        databases: [{ db, schema: { users } }],
    });
    // You should choose to use either `resources` or `databases`
};

Examples

Example projects for the different adapters can be found in the test directory of the repository.