Added some new tests
This commit is contained in:
parent
0039a8b4ec
commit
918f873fea
15 changed files with 887 additions and 114 deletions
|
@ -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
24
models/carscolors.js
Normal 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
11
models/colors.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
module.exports = (sequelize, DataTypes) => {
|
||||
const Colors = sequelize.define(
|
||||
"Colors",
|
||||
{
|
||||
name: DataTypes.STRING
|
||||
},
|
||||
{}
|
||||
);
|
||||
|
||||
return Colors;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue