Mise à jour de controleurs, models et routes
This commit is contained in:
@@ -26,6 +26,30 @@ class ArticleService {
|
||||
order: [['createdAt', 'DESC']],
|
||||
});
|
||||
}
|
||||
|
||||
static async getArticleBySlug(slug) {
|
||||
const articles = await Article.findAll({
|
||||
where: { slug },
|
||||
include: [
|
||||
{ model: DB.Tag, as: "tagNameTagTagLists", attributes: ["name"], through: { attributes: [] } },
|
||||
{ model: DB.User, as: "author", attributes: { exclude: ["email", "phone", "salt", "hash"] } },
|
||||
//{ model: DB.User, as: "author", attributes: { include: ["id", "username", "image", "role"] } },
|
||||
],
|
||||
order: [['createdAt', 'DESC']],
|
||||
});
|
||||
/*
|
||||
.then(data => {
|
||||
data.tagList = data.tagNameTagTagLists;
|
||||
delete data.tagNameTagTagLists;
|
||||
return data;
|
||||
});
|
||||
*/
|
||||
//let article = articles[0];
|
||||
//article.tagList = article.tagNameTagTagLists;
|
||||
//delete article.tagNameTagTagLists;
|
||||
|
||||
return articles[0];
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ArticleService;
|
||||
@@ -18,7 +18,11 @@ class UserService {
|
||||
}
|
||||
|
||||
static async getUserByEmail(email) {
|
||||
return User.findOne(email);
|
||||
return User.findOne({ where: { email: email } });
|
||||
}
|
||||
|
||||
static async updateUser(data) {
|
||||
return User.update(data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user