roles

package
v5.4.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

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) Get

func (r *PostgresRepository) Get(roleUUID uuid.UUID) (Role, bool, error)

Get search and returns an User Role from the repository by its id

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 (r *PostgresRepository) SetRolePermissions(roleUUID uuid.UUID, permissionUUIDs []uuid.UUID) error

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

func R

func R() Repository

R is used to access the global repository singleton

type Role

type Role struct {
	ID   uuid.UUID `json:"id"`
	Name string    `json:"name"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL