我正在为我的项目使用Sequelize v5.0,我有两个定义如下的模型:
user.js
包括用户模型//USER MODEL in user.js
const Sequelize = require("sequelize");
const db = require("../config/database");
const Conversation = require("./conversation");
const Participation = require("./participation");
const User = db.define("users", {
//...attributes
});
User.belongsToMany(Conversation, { through: Participation });
module.exports = User;
conversation.js
包括会话模型const Sequelize = require("sequelize");
const db = require("../config/database");
const User = require("./user");
const Participation = require("./participation");
const Conversation = db.define("conversations", {
//...attributes
});
Conversation.belongsToMany(User, { through: Participation });
module.exports = Conversation;
当我运行项目时,它会引发以下错误:
Error: conversations.belongsToMany called with something that's not a subclass of Sequelize.Model
at Function.belongsToMany (/home/phandungtri/Projects/CodeChat/node_modules/sequelize/lib/associations/mixin.js:49:13)
at Object.<anonymous> (/home/phandungtri/Projects/CodeChat/models/conversation.js:22:14)
...
conversations.belongsToMany调用了什么不是Sequelize.Model的子类是什么意思?