ORE Studio 0.0.4
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
account_role_repository Class Reference

Reads and writes account-role assignments to data storage. More...

#include <account_role_repository.hpp>

Collaboration diagram for account_role_repository:
Collaboration graph

Public Types

using context = ores::database::context
 

Public Member Functions

 account_role_repository (context ctx)
 
std::string sql ()
 Returns the SQL created by sqlgen to construct the table.
 
std::vector< domain::account_roleread_latest ()
 Reads all active account-role assignments.
 
std::vector< domain::account_roleread_latest_by_account (const boost::uuids::uuid &account_id)
 Reads all roles assigned to a specific account.
 
std::vector< domain::account_roleread_latest_by_role (const boost::uuids::uuid &role_id)
 Reads all accounts assigned to a specific role.
 
bool exists (const boost::uuids::uuid &account_id, const boost::uuids::uuid &role_id)
 Checks if a specific account-role assignment exists.
 
void remove (const boost::uuids::uuid &account_id, const boost::uuids::uuid &role_id)
 Removes a specific account-role assignment.
 
void remove_all_for_account (const boost::uuids::uuid &account_id)
 Removes all role assignments for an account.
 
std::vector< std::string > read_effective_permissions (const boost::uuids::uuid &account_id)
 Gets all effective permission codes for an account in a single query.
 
std::vector< domain::roleread_roles_with_permissions (const boost::uuids::uuid &account_id)
 Gets all roles assigned to an account with their permissions.
 
void write (const domain::account_role &account_role)
 Writes account-role assignments to database.
 
void write (const std::vector< domain::account_role > &account_roles)
 

Detailed Description

Reads and writes account-role assignments to data storage.

Member Function Documentation

◆ exists()

bool exists ( const boost::uuids::uuid &  account_id,
const boost::uuids::uuid &  role_id 
)

Checks if a specific account-role assignment exists.

More efficient than read_latest_by_account when only checking existence.

Here is the caller graph for this function:

◆ read_effective_permissions()

std::vector< std::string > read_effective_permissions ( const boost::uuids::uuid &  account_id)

Gets all effective permission codes for an account in a single query.

This method uses JOINs to efficiently fetch all distinct permission codes assigned to an account through its roles, avoiding the N+1 query problem.

Here is the caller graph for this function:

◆ read_roles_with_permissions()

std::vector< domain::role > read_roles_with_permissions ( const boost::uuids::uuid &  account_id)

Gets all roles assigned to an account with their permissions.

This method efficiently fetches all roles for an account along with their permission codes in a single database query, avoiding N+1 issues.

Here is the caller graph for this function: