Mise à jour et ajout de controllers, routes, services et utilities
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
const DB = require('../mysql');
|
||||
|
||||
const associate = () => {
|
||||
DB.Article.belongsToMany(DB.Tag, { as: 'articleTags', through: DB.TagList, foreignKey: "articleId", otherKey: "tagName" });
|
||||
DB.Article.belongsToMany(DB.User, { as: 'userIdUsers', through: DB.Favorite, foreignKey: "articleId", otherKey: "userId" });
|
||||
DB.Article.belongsToMany(DB.Tag, { as: 'articleTags', through: DB.TagList, foreignKey: "articleId", otherKey: "tagName", onDelete: "CASCADE" });
|
||||
DB.Product.belongsToMany(DB.Tag, { as: 'productTags', through: DB.ProductTagXref, foreignKey: "productId", otherKey: "tagName", onDelete: "CASCADE" });
|
||||
DB.Article.belongsToMany(DB.User, { as: 'articleFavoriteUsers', through: DB.Favorite, foreignKey: "articleId", otherKey: "userId", onDelete: "CASCADE" });
|
||||
DB.Category.belongsToMany(DB.Product, { as: 'productIdProducts', through: DB.ProductCategoryXref, foreignKey: "categoryId", otherKey: "productId" });
|
||||
DB.Product.belongsToMany(DB.Category, { as: 'productCategories', through: DB.ProductCategoryXref, foreignKey: "productId", otherKey: "categoryId" });
|
||||
DB.Product.belongsToMany(DB.Tag, { as: 'productTags', through: DB.ProductTagXref, foreignKey: "productId", otherKey: "tagName" });
|
||||
DB.Role.belongsToMany(DB.User, { as: 'userIdUserUserRoleXrefs', through: DB.UserRoleXref, foreignKey: "roleId", otherKey: "userId" });
|
||||
DB.Tag.belongsToMany(DB.Article, { as: 'articleIdArticleTagLists', through: DB.TagList, foreignKey: "tagName", otherKey: "articleId" });
|
||||
DB.Tag.belongsToMany(DB.Product, { as: 'productIdProductProductTagXrefs', through: DB.ProductTagXref, foreignKey: "tagName", otherKey: "productId" });
|
||||
@@ -14,11 +14,11 @@ const associate = () => {
|
||||
DB.User.belongsToMany(DB.User, { as: 'followerIdUsers', through: DB.Follower, foreignKey: "userId", otherKey: "followerId" });
|
||||
DB.User.belongsToMany(DB.User, { as: 'userIdUserFollowers', through: DB.Follower, foreignKey: "followerId", otherKey: "userId" });
|
||||
DB.Comment.belongsTo(DB.Article, { as: "article", foreignKey: "articleId"});
|
||||
DB.Article.hasMany(DB.Comment, { as: "comments", foreignKey: "articleId"});
|
||||
DB.Article.hasMany(DB.Comment, { as: "comments", foreignKey: "articleId", onDelete: "CASCADE"});
|
||||
DB.Favorite.belongsTo(DB.Article, { as: "article", foreignKey: "articleId"});
|
||||
DB.Article.hasMany(DB.Favorite, { as: "favorites", foreignKey: "articleId"});
|
||||
DB.Article.hasMany(DB.Favorite, { as: "favorites", foreignKey: "articleId", onDelete: "CASCADE"});
|
||||
DB.TagList.belongsTo(DB.Article, { as: "article", foreignKey: "articleId"});
|
||||
DB.Article.hasMany(DB.TagList, { as: "tagLists", foreignKey: "articleId"});
|
||||
DB.Article.hasMany(DB.TagList, { as: "tagLists", foreignKey: "articleId", onDelete: "CASCADE"});
|
||||
DB.Product.belongsTo(DB.Brand, { as: "brand", foreignKey: "brandId"});
|
||||
DB.Brand.hasMany(DB.Product, { as: "products", foreignKey: "brandId"});
|
||||
DB.ProductCategoryXref.belongsTo(DB.Category, { as: "category", foreignKey: "categoryId"});
|
||||
@@ -34,11 +34,11 @@ const associate = () => {
|
||||
DB.ProductTagXref.belongsTo(DB.Tag, { as: "tagNameTag", foreignKey: "tagName"});
|
||||
DB.Tag.hasMany(DB.ProductTagXref, { as: "productTagXrefs", foreignKey: "tagName"});
|
||||
DB.TagList.belongsTo(DB.Tag, { as: "tagNameTag", foreignKey: "tagName"});
|
||||
DB.Tag.hasMany(DB.TagList, { as: "tagLists", foreignKey: "tagName"});
|
||||
DB.Tag.hasMany(DB.TagList, { as: "tagLists", foreignKey: "tagName", onDelete: "CASCADE"});
|
||||
DB.Article.belongsTo(DB.User, { as: "author", foreignKey: "authorId"});
|
||||
DB.User.hasMany(DB.Article, { as: "articles", foreignKey: "authorId"});
|
||||
DB.User.hasMany(DB.Article, { as: "articles", foreignKey: "authorId", onDelete: "CASCADE"});
|
||||
DB.Comment.belongsTo(DB.User, { as: "author", foreignKey: "authorId"});
|
||||
DB.User.hasMany(DB.Comment, { as: "comments", foreignKey: "authorId"});
|
||||
DB.User.hasMany(DB.Comment, { as: "comments", foreignKey: "authorId", onDelete: "CASCADE"});
|
||||
DB.Favorite.belongsTo(DB.User, { as: "user", foreignKey: "userId"});
|
||||
DB.User.hasMany(DB.Favorite, { as: "favorites", foreignKey: "userId"});
|
||||
DB.Follower.belongsTo(DB.User, { as: "user", foreignKey: "userId"});
|
||||
|
||||
Reference in New Issue
Block a user