This is an AdminJS adapter which integrates Drizzle ORM into AdminJS.
yarn
$ yarn add adminjs-drizzle
npm
$ npm i adminjs-drizzle
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';
async function setupAdminJs() {
// For available database connections please refer to the Drizzle ORM documentation.
const client = postgres('postgres://user:password@host:port/db');
const db = drizzle(queryClient);
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`
};
Example projects for the different adapters can be found in the test
directory of the repository.