sequelize-middleware/models/brands.js
2020-02-11 15:38:28 +01:00

19 lines
326 B
JavaScript

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;
};