sequelize-middleware/models/brands.js

20 lines
326 B
JavaScript
Raw Normal View History

module.exports = (sequelize, DataTypes) => {
const Brands = sequelize.define(
"Brands",
{
name: DataTypes.STRING
},
{}
);
Brands.associate = function(models) {
Brands.hasMany(models.Cars, {
as: "Cars",
foreignKey: "brandId",
sourceKey: "id"
});
};
return Brands;
};