Commit ad70cd38 authored by Yoon, Daeki's avatar Yoon, Daeki 😅
Browse files

역할 디비 기능 추가

parent 256b8285
export * as userDb from "./user.db"; export * as userDb from "./user.db";
export * as roleDb from "./role.db";
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;
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment