Documentation ¶
Index ¶
- func ReplaceGlobals(repository Repository) func()
- type PostgresRepository
- func (r *PostgresRepository) Create(role Role) (uuid.UUID, error)
- func (r *PostgresRepository) Delete(uuid uuid.UUID) error
- func (r *PostgresRepository) Get(roleUUID uuid.UUID) (Role, bool, error)
- func (r *PostgresRepository) GetAll() ([]Role, error)
- func (r *PostgresRepository) GetAllForUser(userUUID uuid.UUID) ([]Role, error)
- func (r *PostgresRepository) GetByName(name string) (Role, bool, error)
- func (r *PostgresRepository) SetRolePermissions(roleUUID uuid.UUID, permissionUUIDs []uuid.UUID) error
- func (r *PostgresRepository) Update(role Role) error
- type Repository
- type Role
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReplaceGlobals ¶
func ReplaceGlobals(repository Repository) func()
ReplaceGlobals affect a new repository to the global repository singleton
Types ¶
type PostgresRepository ¶
type PostgresRepository struct {
// contains filtered or unexported fields
}
PostgresRepository is a repository containing the user roles data based on a PSQL database and implementing the repository interface
func (*PostgresRepository) Create ¶
func (r *PostgresRepository) Create(role Role) (uuid.UUID, error)
Create creates a new User Role in the repository
func (*PostgresRepository) Delete ¶
func (r *PostgresRepository) Delete(uuid uuid.UUID) error
Delete deletes an User Role in the repository
func (*PostgresRepository) GetAll ¶
func (r *PostgresRepository) GetAll() ([]Role, error)
GetAll returns all User Roles in the repository
func (*PostgresRepository) GetAllForUser ¶
func (r *PostgresRepository) GetAllForUser(userUUID uuid.UUID) ([]Role, error)
func (*PostgresRepository) GetByName ¶
func (r *PostgresRepository) GetByName(name string) (Role, bool, error)
GetByName search and returns an User Role from the repository by its id
func (*PostgresRepository) SetRolePermissions ¶
func (*PostgresRepository) Update ¶
func (r *PostgresRepository) Update(role Role) error
Update updates an User Role in the repository
type Repository ¶
type Repository interface { Get(uuid uuid.UUID) (Role, bool, error) GetByName(name string) (Role, bool, error) Create(permission Role) (uuid.UUID, error) Update(permission Role) error Delete(uuid uuid.UUID) error GetAll() ([]Role, error) GetAllForUser(userUUID uuid.UUID) ([]Role, error) SetRolePermissions(roleUUID uuid.UUID, permissionUUIDs []uuid.UUID) error }
Repository is a storage interface which can be implemented by multiple backend (in-memory map, sql database, in-memory cache, file system, ...) It allows standard CRUD operation on facts
func NewPostgresRepository ¶
func NewPostgresRepository(dbClient *sqlx.DB) Repository
NewPostgresRepository returns a new instance of PostgresRepository