SoftwareBrothers / adminjs

AdminJS is an admin panel for apps written in node.js
https://adminjs.co
MIT License
8.21k stars 662 forks source link

Error message: You have to specify "recordId" for record action #367

Closed dhemas closed 4 years ago

dhemas commented 4 years ago

Describe the bug AdminBro gives me error about unspecified recordId as shown below

screenshot

Installed libraries and their versions

To Reproduce Steps to reproduce the behavior:

  1. Init sequelize with sequelize-cli init
  2. Generate sequelize models with sequelize-auto
  3. Run app with minimal config (mostly default)

AdminBroOptions with schema

// adminbro options
const adminBro = new AdminBro({
  // databases: [db],
  resources: [{
    resource: db.user_status,
    options: {
      //...
    }
  }],
  rootPath: '/admin',
})

// schema
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('user_status', {
    id: {
      type: DataTypes.INTEGER(4),
      allowNull: false,
      primaryKey: true
    },
    status: {
      type: DataTypes.STRING(255),
      allowNull: false,
      unique: true
    }
  }, {
    tableName: 'user_status'
  });
};

Desktop (please complete the following information if relevant):

dhemas commented 4 years ago

NVM, I just realized that sequelize model should have an auto increment primary key

wojtek-krysiak commented 4 years ago

please paste content from options:

resources: [{
    resource: db.user_status,
    options: {
      //... PASTE WHAT IS HERE
    }
  }],

most probably you define some after hooks which returns objects without { record } property

uvios commented 4 years ago

@wojtek-krysiak I am facing this issue const adminBro = new AdminBro({ rootPath: '/admin', resources: [{ resource: DstvPackages, options: {}}], branding: { companyName: 'abc', }, })

node v10.19.0

uvios commented 4 years ago

also it works fine with sample data. but when i connect it data previously used by application I am facing this

wojtek-krysiak commented 4 years ago

maybe because the previous records didn't have this primary Id column?