From: charleswrayjr Date: Fri, 12 Sep 2025 04:35:26 +0000 (-0500) Subject: Adding get_user_roles to user.model.js. X-Git-Url: https://git.phasecustomsoft.com/static/git-logo.png?a=commitdiff_plain;h=67731d416081d2b6fc507f4e9554540b55b55fc9;p=phs-api.git Adding get_user_roles to user.model.js. --- diff --git a/src/models/user.model.js b/src/models/user.model.js index 5e3af78..94edaea 100644 --- a/src/models/user.model.js +++ b/src/models/user.model.js @@ -110,6 +110,16 @@ class User extends Model { return new User( result ); }; + async get_user_roles() { + const query_str = ` + SELECT r.* + FROM phase.user_roles ur + inner join phase.roles r on r.id = ur.role_id + WHERE ur.user_id = $1 and r.is_deleted = false + `; + return await phsdb.query( query_str, [this.id], { plain:true } ); + }; + /** * Find user by email * @param {string} email - Email to search for