Documentation ¶
Index ¶
- func ReplaceGlobals(repository Repository) func()
- type PostgresRepository
- func (r *PostgresRepository) Create(tx *sqlx.Tx, action models.Action) (int64, error)
- func (r *PostgresRepository) Delete(tx *sqlx.Tx, id int64) error
- func (r *PostgresRepository) Get(id int64) (models.Action, bool, error)
- func (r *PostgresRepository) GetAll() (map[int64]models.Action, error)
- func (r *PostgresRepository) GetAllByRootCauseID(rootCauseID int64) (map[int64]models.Action, error)
- func (r *PostgresRepository) GetAllBySituationID(situationID int64) (map[int64]models.Action, error)
- func (r *PostgresRepository) Update(tx *sqlx.Tx, id int64, action models.Action) error
- type Repository
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 Action definition based on a PSQL database and implementing the repository interface
func (*PostgresRepository) Delete ¶
func (r *PostgresRepository) Delete(tx *sqlx.Tx, id int64) error
Delete use to retrieve an action by id
func (*PostgresRepository) GetAll ¶
func (r *PostgresRepository) GetAll() (map[int64]models.Action, error)
GetAll method used to get all actions
func (*PostgresRepository) GetAllByRootCauseID ¶
func (r *PostgresRepository) GetAllByRootCauseID(rootCauseID int64) (map[int64]models.Action, error)
GetAllByRootCauseID method used to get all actions for a specific rootcause ID
func (*PostgresRepository) GetAllBySituationID ¶
func (r *PostgresRepository) GetAllBySituationID(situationID int64) (map[int64]models.Action, error)
GetAllBySituationID method used to get all actions for a specific situation ID
type Repository ¶
type Repository interface { Get(id int64) (models.Action, bool, error) Create(tx *sqlx.Tx, action models.Action) (int64, error) Update(tx *sqlx.Tx, id int64, action models.Action) error Delete(tx *sqlx.Tx, id int64) error GetAll() (map[int64]models.Action, error) GetAllByRootCauseID(rootCauseID int64) (map[int64]models.Action, error) GetAllBySituationID(situationID int64) (map[int64]models.Action, 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 Actions
func NewPostgresRepository ¶
func NewPostgresRepository(dbClient *sqlx.DB) Repository
NewPostgresRepository returns a new instance of PostgresRepository