]> PHS Git Server - phs-api.git/commitdiff
Adding get_user_roles to user.model.js.
authorcharleswrayjr <charleswrayjr@gmail.com>
Fri, 12 Sep 2025 04:35:26 +0000 (23:35 -0500)
committercharleswrayjr <charleswrayjr@gmail.com>
Fri, 12 Sep 2025 04:35:26 +0000 (23:35 -0500)
src/models/user.model.js

index 5e3af78f6fa564b5bb65f1f5e1c0758e71398007..94edaeac283b7301e7c58f92ab75e48ba5f82f41 100644 (file)
@@ -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