Improved part of the performance of the dashboards
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {Role} from "@/interfaces/entity";
|
||||
import { Role } from "@/interfaces/entity";
|
||||
import client from "@/lib/mongodb";
|
||||
|
||||
const db = client.db(process.env.MONGODB_DB);
|
||||
@@ -6,16 +6,18 @@ const db = client.db(process.env.MONGODB_DB);
|
||||
export const getRolesByEntities = async (entityIDs: string[]) =>
|
||||
await db
|
||||
.collection("roles")
|
||||
.find<Role>({entityID: {$in: entityIDs}})
|
||||
.find<Role>({ entityID: { $in: entityIDs } })
|
||||
.toArray();
|
||||
|
||||
export const getRolesByEntity = async (entityID: string) => await db.collection("roles").find<Role>({entityID}).toArray();
|
||||
export const getRolesByEntity = async (entityID: string) => await db.collection("roles").find<Role>({ entityID }).toArray();
|
||||
|
||||
export const getRoles = async (ids?: string[]) => await db.collection("roles").find<Role>(!ids ? {} : {id: {$in: ids}}).toArray();
|
||||
export const getRole = async (id: string) => (await db.collection("roles").findOne<Role>({id})) ?? undefined;
|
||||
export const getRoles = async (ids?: string[]) => await db.collection("roles").find<Role>(!ids ? {} : { id: { $in: ids } }).toArray();
|
||||
export const getRole = async (id: string) => (await db.collection("roles").findOne<Role>({ id })) ?? undefined;
|
||||
|
||||
export const getDefaultRole = async (entityID: string) => await db.collection("roles").findOne<Role>({ isDefault: true, entityID })
|
||||
|
||||
export const createRole = async (role: Role) => await db.collection("roles").insertOne(role)
|
||||
export const deleteRole = async (id: string) => await db.collection("roles").deleteOne({id})
|
||||
export const deleteRole = async (id: string) => await db.collection("roles").deleteOne({ id })
|
||||
|
||||
export const transferRole = async (previousRole: string, newRole: string) =>
|
||||
await db.collection("users")
|
||||
|
||||
Reference in New Issue
Block a user