node js sequelize在模型内部定义一个具有其他模型类型的字段
我试图导入模型并为字段提供模型的类型,但是我收到错误,指出它无法分配。
import { User } from './';
followerId: {
type: User,
allowNull: false,
}
回答如下:要实现您需要关联:
https://sequelize/master/manual/assocs.html
YourModel.hasMany(User, {
foreignKey: {
name: 'followerId'
}
});
User.belongsTo(YourModel);
评论列表(0)
- 暂无评论