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 22:00:03 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ee273d23f310e20925670ccc1f6ec2347841b847
ee273d23
1 parent
a1bc328c
ADD: function getting Users by keyword
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 @
ee273d2
...
...
@@ -73,6 +73,29 @@ database.getKeywordsByUserId = async function(userId) {
return
result
}
database
.
getUsersByKeyword
=
async
function
(
keyword
)
{
const
users
=
await
User
.
findAll
({
attributes
:
[
'userId'
],
where
:
{
'$keyword.keyword$'
:
keyword
},
include
:
[{
attributes
:
[],
model
:
Keyword
,
as
:
'keyword'
}],
raw
:
true
})
let
result
=
[]
for
(
let
i
=
0
;
i
<
users
.
length
;
i
++
)
{
result
.
push
(
users
[
i
].
userId
)
}
return
result
}
database
.
getAllUsers
=
async
function
()
{
const
users
=
await
User
.
findAll
({
...
...
server/app.js
View file @
ee273d2
...
...
@@ -14,6 +14,7 @@ sequelize.sync({ force: false })
database
.
getKeywordsByUserId
(
"junseok"
)
database
.
deleteKeyword
(
"phobyjun"
,
"rtx3080"
)
database
.
getAllUsers
()
database
.
getUsersByKeyword
(
"rtx3060"
)
})
.
catch
((
err
)
=>
{
console
.
log
(
'database connection failed'
);
...
...
Please
register
or
login
to post a comment