Continued creating the entity system
This commit is contained in:
14
src/utils/roles.be.ts
Normal file
14
src/utils/roles.be.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import {Role} from "@/interfaces/entity";
|
||||
import client from "@/lib/mongodb";
|
||||
|
||||
const db = client.db(process.env.MONGODB_DB);
|
||||
|
||||
export const getRolesByEntities = async (entityIDs: string[]) =>
|
||||
await db
|
||||
.collection("roles")
|
||||
.find<Role>({entityID: {$in: entityIDs}})
|
||||
.toArray();
|
||||
|
||||
export const getRolesByEntity = async (entityID: string) => await db.collection("roles").find<Role>({entityID}).toArray();
|
||||
|
||||
export const getRole = async (id: string) => (await db.collection("roles").findOne<Role>({id})) ?? undefined;
|
||||
Reference in New Issue
Block a user