你好我的地址模型
const { DataTypes } = require('sequelize');
const sequelize = require('../../../db/connection');
var BorrowerInfo = require('../../models/borrowerInfo/BorrowerInfo')
const Address = sequelize.define('addresses', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
allowNull: false,
},
street: {
type: DataTypes.STRING,
allowNull: false
},
unit: {
type: DataTypes.STRING,
allowNull: false
},
city: {
type: DataTypes.STRING,
allowNull: false
},
state: {
type: DataTypes.STRING,
allowNull: false
},
zip: {
type: DataTypes.STRING,
allowNull: false
},
country: {
type: DataTypes.STRING,
allowNull: false
},
},
{
freezeTableName: true
},
{
}
);
Address.associate = (models) => {
Address.belongsToMany(BorrowerInfo, {
through: 'BorrowerAddresses',
as: 'address',
foreignKey: 'addressId'
});
};
module.exports = Address;
我的借款人模型
const { DataTypes } = require('sequelize');
const sequelize = require('../../../db/connection');
const Address = require('../../models/common/Address')
const BorrowerInfo = sequelize.define('borrower_info', {
id : {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true ,
allowNull: false,
},
loanAppNo : {
type: DataTypes.STRING,
allowNull: false
},
firstName: {
type: DataTypes.STRING,
allowNull: false
},
lastName: {
type: DataTypes.STRING,
allowNull: false
},
middleName:{
type: DataTypes.STRING,
allowNull: false
},
suffix: {
type: DataTypes.STRING,
allowNull: false
},
ssn: {
type: DataTypes.STRING,
allowNull: false
},
dob: {
type: DataTypes.DATE,
allowNull: false
},
citizenship: {
type: DataTypes.STRING,
allowNull: false
},
maritalStatus: {
type: DataTypes.ENUM('1','2','3'),
},
noOfDependantChilds: {
type: DataTypes.INTEGER,
allowNull: false
},
agesDependantChilds: {
type: DataTypes.STRING,
allowNull: false
},
contactInfo: {
type: DataTypes.JSON,
allowNull: false
},
createdAt: {
type: DataTypes.NOW,
}
},
{
timestamps: false,
freezeTableName: true
},
{
}
);
BorrowerInfo.belongsToMany(Address, {
through: 'borrower_addresses',
});
module.exports = BorrowerInfo;
我的借款人地址模型
const {
DataTypes
} = require('sequelize');
var Addresses = require('../common/Address')
const sequelize = require('../../../db/connection');
const BorrowerAddresses = sequelize.define('borrower_addresses', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
allowNull: false,
},
borrowerInfoId: {
type: DataTypes.INTEGER,
allowNull: false
},
type: {
type: DataTypes.ENUM('current', 'former', 'mailing'),
allowNull: false
},
addressId: {
type: DataTypes.INTEGER,
allowNull: false
},
howLongAtCurrentAddress: {
type: DataTypes.INTEGER,
allowNull: false
},
housing: {
type: DataTypes.ENUM('1', '2', '3'),
},
rentPerMonth: {
type: DataTypes.FLOAT,
allowNull: false
},
createdAt: {
type: DataTypes.NOW,
}
}, {
timestamps: false,
freezeTableName: true
});
module.exports = BorrowerAddresses;
错误:rower_info.belongsToMany被调用,而不是Sequelize.Model的子类。]
当我在下面的借款人信息模型中安慰地址模型时BorrowerInfo:类扩展了模型{}地址:{}
地址模型没有扩展模型类
但是当我在地址模型中合并借款人信息模型时,它正在扩展模型类,这是什么问题,请指导我如何摆脱此错误
请标记一些可以帮助的人
你好我的地址模型const {DataTypes} = require('sequelize'); const sequelize = require('../../../ db / connection'); var BorrowerInfo = require('../../ models / borrowerInfo / BorrowerInfo')const ...
您的模型定义是实际的模型名称。因此,使模型名称与如下定义相同。