Запрос из нескольких таблиц Sequelize
Всем привет. Объясните пожалуйста как правильно делать запрос из нескольких таблиц через sequelize? у меня есть такой код:
const Products = sequelize.define('products', {
ID_Product: {type: types.INTEGER, primaryKey: true, autoIncrement: true, allowNull: false},
Name: {type: types.STRING, allowNull: false},
Price: {type: types.INTEGER, allowNull: false},
Availability: {type: types.BOOLEAN, allowNull: false, defaultValue: 1},
Manufacturer: {type: types.STRING, allowNull: false},
PhotoPath: {type: types.STRING, allowNull: false}
});
const Categories = sequelize.define('categories', {
ID_Category: {type: types.INTEGER, primaryKey: true, autoIncrement: true, allowNull: false},
Category: {type: types.STRING, allowNull: false}
});
const Types = sequelize.define('types', {
ID_Type: {type: types.INTEGER, primaryKey: true, autoIncrement: true, allowNull: false},
Type: {type: types.STRING, allowNull: false}
});
const Descriptions = sequelize.define('descriptions', {
ID_Description: {type: types.INTEGER, primaryKey: true, autoIncrement: true, allowNull: false},
Description: {type: types.TEXT, allowNull: false}
});
const Characteristics = sequelize.define('characteristics', {
ID_Characteristic: {type: types.INTEGER, primaryKey: true, autoIncrement: true, allowNull: false},
Characteristic: {type: types.STRING, allowNull: false},
Value:{type: types.STRING, allowNull: false}
});
roles.hasMany(users); // Связь один ко многим
users.belongsTo(roles);
roles.hasOne(access); // Связь один к одному
access.belongsTo(roles);
access.hasMany(products);
products.belongsTo(access);
categories.hasMany(types);
types.belongsTo(categories);
types.hasMany(products);
products.belongsTo(types);
products.hasMany(characteristics);
characteristics.belongsTo(products);
products.hasMany(descriptions);
descriptions.belongsTo(products);