Documentation ¶
Index ¶
- func ReplaceGlobals(repository Repository) func()
- type PostgresRepository
- func (r *PostgresRepository) Create(userWithPass security.UserWithPassword) (int64, error)
- func (r *PostgresRepository) Delete(id int64) error
- func (r *PostgresRepository) Get(id int64) (security.User, bool, error)
- func (r *PostgresRepository) GetAll() (map[int64]security.User, error)
- func (r *PostgresRepository) GetUsersOfGroup(groupID int64) (map[int64]UserOfGroup, error)
- func (r *PostgresRepository) Update(userWithPass security.User) error
- func (r *PostgresRepository) UpdatePassword(userWithPass security.UserWithPassword) error
- type Repository
- type UserOfGroup
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 users data based on a PSQL database and implementing the repository interface
func (*PostgresRepository) Create ¶
func (r *PostgresRepository) Create(userWithPass security.UserWithPassword) (int64, error)
Create creates a new User in the repository
func (*PostgresRepository) Delete ¶
func (r *PostgresRepository) Delete(id int64) error
Delete deletes an User in the repository
func (*PostgresRepository) GetAll ¶
func (r *PostgresRepository) GetAll() (map[int64]security.User, error)
GetAll returns all users in the repository
func (*PostgresRepository) GetUsersOfGroup ¶
func (r *PostgresRepository) GetUsersOfGroup(groupID int64) (map[int64]UserOfGroup, error)
GetUsersOfGroup returns all users of a Group in the repository
func (*PostgresRepository) Update ¶
func (r *PostgresRepository) Update(userWithPass security.User) error
Update updates an User in the repository
func (*PostgresRepository) UpdatePassword ¶
func (r *PostgresRepository) UpdatePassword(userWithPass security.UserWithPassword) error
UpdatePassword updates an User password in the repository
type Repository ¶
type Repository interface { Get(id int64) (security.User, bool, error) Create(user security.UserWithPassword) (int64, error) Update(user security.User) error Delete(id int64) error GetAll() (map[int64]security.User, error) GetUsersOfGroup(groupID int64) (map[int64]UserOfGroup, 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 PostgresRulesRepository
type UserOfGroup ¶
UserOfGroup user in a group