Added some new tests

This commit is contained in:
Damien Broqua 2020-02-13 22:36:14 +01:00
parent 0039a8b4ec
commit 918f873fea
15 changed files with 887 additions and 114 deletions

View file

@ -21,6 +21,7 @@ module.exports = (sequelize, DataTypes) => {
as: "Brand",
foreignKey: "brandId"
});
Cars.belongsToMany(models.Colors, { through: models.CarsColors });
};
return Cars;

24
models/carscolors.js Normal file
View file

@ -0,0 +1,24 @@
module.exports = (sequelize, DataTypes) => {
const CarsColors = sequelize.define(
"CarsColors",
{
CarId: {
type: DataTypes.INTEGER,
references: {
model: "Cars",
key: "id"
}
},
ColorId: {
type: DataTypes.INTEGER,
references: {
model: "Colors",
key: "id"
}
}
},
{}
);
return CarsColors;
};

11
models/colors.js Normal file
View file

@ -0,0 +1,11 @@
module.exports = (sequelize, DataTypes) => {
const Colors = sequelize.define(
"Colors",
{
name: DataTypes.STRING
},
{}
);
return Colors;
};