'nodejs adminBro mysql There are no adapters supporting one of the resource you provided

I have been trying to implement Admin Bro with my existing mysql sequelized database. I get plain Admin panel and it works fine, however when i try to fetch db i get: There are no adapters supporting one of the resource you provided error. Please help.

UserModel

import {Sequelize} from "sequelize";
import db from "../config/database.js";

const {DataTypes} = Sequelize;

const Users = db.define('user', {
    name: {
        type: DataTypes.STRING
    },
    surname: {
        type: DataTypes.STRING
    },
    email: {
        type: DataTypes.STRING
    },
    password: {
        type: DataTypes.STRING
    },
    refresh_token:{
        type: DataTypes.TEXT
    },
    token:{
        type: DataTypes.TEXT
    }

}, {
    freezeTableName: true,
    timestamps:false
});
(async () => {
    await db.sync()
})();

export default Users;

database

import { Sequelize } from "sequelize";

const db = new Sequelize('users', 'root', '*********', {
    host: "localhost",
    dialect: "mysql"
});

export default db;

adminBro

import AdminBro from "admin-bro";
import Users from '../models/UserModel.js'
const adminBro = new AdminBro({
    rootPath: '/admin',
    loginPath: '/admin/login',
    databases:[Users],
    branding: {
        companyName: 'Admin',
        softwareBrothers: false,
    }
});
export default adminBro


Solution 1:[1]

To see your entire db within the AdminBro panel import the db file and use that

please use the below code:


const AdminBro = require('admin-bro')
const AdminBroExpress = require('admin-bro-expressjs');
const AdminBroSequelize = require('admin-bro-sequelizejs');
const db = require('../database/models');

const express = require('express')
const app = express();

AdminBro.registerAdapter(AdminBroSequelize);

const adminBro = new AdminBro({
  databases: [db],
  rootPath: '/admin',
})

module.exports =  adminBro;

If you want individual resource then follow this link: add resource and customize resource


const adminBro = new AdminBro({
    resources: [User],
    //... other AdminBroOptions
  })

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Akhil Nayak