From fd8b571a7a239e3e9329f99ead160ae7fa8164d1 Mon Sep 17 00:00:00 2001 From: John Schiltz Date: Tue, 6 Sep 2022 15:40:34 -0500 Subject: [PATCH] Fix bug in `addNewRole` switch on wrong field forgot `break` didn't capitalize query field --- rolesOps.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rolesOps.ts b/rolesOps.ts index c890bc5..0f29289 100644 --- a/rolesOps.ts +++ b/rolesOps.ts @@ -63,12 +63,13 @@ export async function addNewRole( ) { // This function is triggered when a user changes their role, it adds the new role to the user let role; - switch (model.constructor) { - case classModel: + switch (model.modelName) { + case "class": //TODO: Rewrite IRole to include name, and replace CODE with name role = await model.findOne({ CODE: id }); + break; default: - role = await model.findOne({ Name: id }); + role = await model.findOne({ NAME: id }); } if (role === null) {