SQL-based database adapter for AdminJS

Overview

adminjs-sql NPM version

This is an inofficial AdminJS adapter which integrates SQL-based database into AdminJS.

Installation: yarn add adminjs-sql

Usage

The plugin can be registered using standard AdminJS.registerAdapter method.

import { Adapter } from 'adminjs-sql';
import AdminJS from 'adminjs';

AdminJS.registerAdapter(Adapter);

After registration, you should call Adapter.init(client, connectionOptions) to parse table information from running database.

// import { Adapter } from 'adminjs-sql';
// ...
const db = await Adapter.init('mysql2', {
  host: DB_HOST,
  port: DB_PORT,
  user: DB_USER,
  password: DB_PASSWORD,
  database: DB_NAME,
});

After initialization, you can register resources. db.tables() to register ALL tables in database. Or you can db.table(tableName) to register specific table.

const adminJs = new AdminJS({
  databases: [db],
  resources: db.tables(),
  // or
  resources: [db.table('users'), db.table('posts'), db.table('comments')],
});

ManyToOne

This supports ManyToOne relationship if you define a foreign key.

Example App

You can run example app with docker.

  1. Clone this repository.
git clone https://github.com/wirekang/adminjs-sql
yarn install
yarn build
  1. Setup example project.
cd example/
yarn install
  1. Run mysql:latest in docker container. Checkout docker-compose.yml
yarn up

  1. Run example app.
yarn start


# Generating samples...
# Inserting samples...
# adminjs-sql example app is under http://localhost:33300
  1. After enjoying the example, you can clean down MySQL server.
yarn down

Testing

We use docker compose to run various databases for testing.

yarn test:up # docker compose up -d

yarn test

yarn test:down # docker compose down

How It Works

adminjs-sql collects information about tables and columns from INFORMATION_SCHEMA and converts to adminjs. This project uses Knex Query Builder to generate SQL string.

Supported Databases

  • MySQL
  • MariaDB

Todo

  • Support Postgres.

  • Elaborate unit testing.

  • Add more complex example app.

Contributions are welcome!!

You might also like...

Qwik City adapter for trpc.io

Qwik City adapter for trpc.io

tRPC 🤝 Qwik City End-to-end typesafe APIs made easy with tRPC.io in Qwik City applications. Build & consume fully typesafe APIs, without schemas or c

Oct 11, 2022

Angular material date-fns adapter (Support jalali)

Angular material date-fns adapter (Support jalali) What is this? This library provides a custom DateAdapter for the Angular Material Datepicker compon

Dec 3, 2022

Interplanetary Database: A Database built on top of IPFS and made immutable using Ethereum blockchain.

IPDB IPDB (Interplanetary Database) is a key/value store database built on top of IPFS (Interplanetary File System). Project is intended to be an MVP

Oct 6, 2022

Visualize, modify, and build your database with dbSpy! An open-source data modeling tool to facilitate relational database development.

Visualize, modify, and build your database with dbSpy! An open-source data modeling tool to facilitate relational database development.

Visualize, modify, and build your database with dbSpy! dbSpy is an open-source data modeling tool to facilitate relational database development. Key F

Dec 22, 2022

A common front-end/Service Worker-based Key/Value database based on CacheStorage

Cache-DB A common front-end/Service Worker-based Key/Value database based on CacheStorage const db = new CacheDB('ChenYFanDB') undefined await d

Sep 30, 2022

Talk about Azure SQL + Prisma

Talk - Power Up Your BackEnd Applications with Serverless Architecture & Azure SQL A demo related with the talk Power Up Your BackEnd Applications wit

Sep 13, 2022

MySQL meets Jupyter notebooks. Grasp provides a new way to learn and write SQL, by providing a coding-notebook style with runnable blocks, markdown documentation, and shareable notebooks. ✨

MySQL meets Jupyter notebooks. Grasp provides a new way to learn and write SQL, by providing a coding-notebook style with runnable blocks, markdown documentation, and shareable notebooks. ✨

A New Way to Write & Learn SQL Report Bug · Request Feature Table of Contents About The Project Built With Getting Started Prerequisites Installation

Sep 1, 2022

ParkyDB - block based, linkable and verifiable document database -- javascript reference implementation

ParkyDB - block based, linkable and verifiable document database -- javascript reference implementation

Ancon ParkyDB A data mesh database using Web 3.0 technology Note: Requires Node v17.7.2 and up for development More about data mesh architecture Block

Aug 16, 2022

VueJS based Shopsystem for the Athena Framework, absolute free and open source! Full Database Integration (MongoDB)

VueJS based Shopsystem for the Athena Framework, absolute free and open source! Full Database Integration (MongoDB)

Open Source Shop Herewith we bring a free store system for the Athena Framework which is under the MIT license and thus can be completely modified and

Oct 31, 2022
Releases(v1.1.2)
Owner
null
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
An exercise in building a very minimal (and very stupid) in-memory SQL-like database for educational purposes.

Stupid Database This is an exercise in building a very minimal (and very stupid) in-memory SQL-like database for educational purposes. None of this co

Fabio Akita 196 Dec 20, 2022
Boost is a Microsoft Excel Add-in to help developers import large excel workbooks into their database using SQL queries

Microsoft Excel Add-in for Developers About Us Boost is a Microsoft Excel Add-in to help developers import large excel workbooks into their database u

OSLabs Beta 30 Sep 30, 2022
An adapter where you can define which function to run

Switch Functions An adapter where you can define which function to run Installation This is a Node.js module available through the npm registry. Befor

Badass Team 2 Jun 17, 2022
A Feathers service adapter for Prisma ORM.

feathers-prisma A Feathers service adapter for Prisma ORM. Installation npm install feathers-prisma --save Documentation This adapter supports all me

Phil 27 Dec 9, 2022
🔨 A more engineered, highly customizable, standard output format commitizen adapter.

cz-git Github | Installation | Website | 简体中文文档 Introduction A more engineered, highly customizable, standard output format commitizen adapter. What i

zhengqbbb 402 Dec 31, 2022
An example on how to use Solana Wallet Adapter as a Web Authentication Method.

Solana Wallet Auth: A FullStack example This example uses Solana's wallet adapter to sign messages and verifies their signatures on the backend, allow

Kevin RodrĂ­guez 19 Dec 20, 2022
Adapter application for consuming web3 messages from ie. wallets, and passing them on to starknet

?? StarknNet web3 account Development setup Clone deps with submodules git clone --recurse-submodules [email protected]:software-mansion-labs/starknet-we

Software Mansion – Labs 20 Nov 21, 2022
Debug Adapter Protocol for Amiga development with FS-UAE or WinUAE

UAE Debug Adapter Protocol Debug Adapter Protocol for Amiga assembly development with FS-UAE or WinUAE. Adapted from @prb28's vscode-amiga-assembly ex

Graham Bates 5 Jul 7, 2022