Toggle navigation
Toggle navigation
This project
Loading...
Sign in
방승일
/
mamuri-bot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
윤준석
2022-05-24 21:49:52 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5dd33fbb6ac9182b79a5b0f28da05365a76b0d90
5dd33fbb
1 parent
aba9519e
ADD: delete keyword from keyword and userId
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
server/apis/database.js
server/app.js
server/apis/database.js
View file @
5dd33fb
...
...
@@ -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
:
{
...
...
server/app.js
View file @
5dd33fb
...
...
@@ -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'
);
...
...
Please
register
or
login
to post a comment