윤준석

ADD: delete keyword from keyword and userId

......@@ -28,7 +28,30 @@ database.addKeyword = async function(keyword, userId) {
})
}
database.deleteKeyword = async function(userId, keyword) {
const u = await User.findOrCreate({
where: {
userId: userId
}
})
const k = await Keyword.findOrCreate({
where: {
keyword: keyword
}
})
await UserKeyword.destroy({
where: {
userId: u[0].id,
keywordId: k[0].id
}
})
}
database.getKeywordsByUserId = async function(userId) {
const keywords = await Keyword.findAll({
attributes: ['keyword'],
where: {
......
......@@ -12,6 +12,7 @@ sequelize.sync({ force: false })
console.log('database connection complete');
database.addKeyword("rtx3060", "junseok")
database.getKeywordsByUserId("junseok")
database.deleteKeyword("phobyjun", "rtx3080")
})
.catch((err) => {
console.log('database connection failed');
......