Closed joon610 closed 3 years ago
working solution
sequelize.define('decks_to_users', {
id: {
type: Sequelize.INTEGER,
autoIncrement: true,
primaryKey: true
},
userId: {
type: Sequelize.INTEGER,
references: {
model: db.User,
key: 'id',
},
}, deckId: {
type: Sequelize.INTEGER,
references: {
model: db.Deck,
key: 'id',
},
},
}, {timestamps: false});
db.User.belongsToMany(db.Deck, {through: 'decks_to_users'})
db.Deck.belongsToMany(db.User, {through: 'decks_to_users'})
thank you comment!
Describe the bug
Installed libraries and their versions "@admin-bro/express": "^3.0.1", "@admin-bro/sequelize": "^1.1.1", "admin-bro": "^3.3.1", "admin-bro-expressjs": "^2.1.1", "admin-bro-sequelizejs": "^0.5.1",
To Reproduce Steps to reproduce the behavior:
Expected behavior A clear and concise description of what you expected to happen.
Screenshots
AdminBroOptions with schema ` //post.js const DataTypes = require('sequelize'); const { Model } = DataTypes;
module.exports = class Post extends Model { static init(sequelize) { return super.init( { content: { type: DataTypes.TEXT, allowNull: true, },
} static associate(db) { db.Post.belongsToMany(db.Student, { through: 'StudentClass', }); } };
module.exports = class Student extends Model { static init(sequelize) { return super.init( { name: { type: DataTypes.STRING(30), allowNull: false, unique: true, }, }, { modelName: 'Student', tableName: 'students', charset: 'utf8', collate: 'utf8_general_ci', sequelize, } ); } static associate(db) { db.Student.belongsToMany(db.Post, { through: 'StudentClass' }); } };
` Desktop (please complete the following information if relevant):
Smartphone (please complete the following information if relevant):
Additional context Add any other context about the problem here.