Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
survey
Commits
ad70cd38
Commit
ad70cd38
authored
Jul 08, 2022
by
Yoon, Daeki
😅
Browse files
역할 디비 기능 추가
parent
256b8285
Changes
2
Show whitespace changes
Inline
Side-by-side
src/db/index.ts
View file @
ad70cd38
export
*
as
userDb
from
"
./user.db
"
;
export
*
as
roleDb
from
"
./role.db
"
;
src/db/role.db.ts
0 → 100644
View file @
ad70cd38
import
{
Role
,
User
}
from
"
../models
"
;
export
const
findRoleById
=
async
(
roleId
:
string
)
=>
{
const
role
=
await
Role
.
findById
(
roleId
);
return
role
;
};
export
const
findRoleByName
=
async
(
roleName
:
string
)
=>
{
const
role
=
await
Role
.
findOne
({
name
:
roleName
});
return
role
;
};
export
const
findRoleByUserId
=
async
(
userId
:
string
)
=>
{
const
user
=
await
User
.
findById
(
userId
).
populate
(
"
role
"
);
const
role
=
user
?.
get
(
"
role
"
);
return
role
;
};
export
const
getAllRoles
=
async
()
=>
{
const
roles
=
await
Role
.
find
({});
return
roles
;
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment