Documentation ¶
Index ¶
- func ReplaceGlobals(repository Repository) func()
- type NativeMapRepository
- func (r *NativeMapRepository) Create(model modeler.Model) (int64, error)
- func (r *NativeMapRepository) Delete(id int64) error
- func (r *NativeMapRepository) Get(id int64) (modeler.Model, bool, error)
- func (r *NativeMapRepository) GetAll() (map[int64]modeler.Model, error)
- func (r *NativeMapRepository) GetAllByIDs(ids []int64) (map[int64]modeler.Model, error)
- func (r *NativeMapRepository) GetByName(name string) (modeler.Model, bool, error)
- func (r *NativeMapRepository) Update(id int64, model modeler.Model) error
- type PostgresRepository
- func (r *PostgresRepository) Create(model modeler.Model) (int64, error)
- func (r *PostgresRepository) Delete(id int64) error
- func (r *PostgresRepository) Get(id int64) (modeler.Model, bool, error)
- func (r *PostgresRepository) GetAll() (map[int64]modeler.Model, error)
- func (r *PostgresRepository) GetAllByIDs(ids []int64) (map[int64]modeler.Model, error)
- func (r *PostgresRepository) GetByName(name string) (modeler.Model, bool, error)
- func (r *PostgresRepository) Update(id int64, model modeler.Model) 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 NativeMapRepository ¶
type NativeMapRepository struct {
// contains filtered or unexported fields
}
NativeMapRepository is an implementation of entity.Repository, supported by standard native in-memory map
func (*NativeMapRepository) Create ¶
func (r *NativeMapRepository) Create(model modeler.Model) (int64, error)
Create stores the given new model in the database as a json.
func (*NativeMapRepository) Delete ¶
func (r *NativeMapRepository) Delete(id int64) error
Delete deletes an entity from the repository by its name
func (*NativeMapRepository) GetAll ¶
func (r *NativeMapRepository) GetAll() (map[int64]modeler.Model, error)
GetAll returns all entities in the repository
func (*NativeMapRepository) GetAllByIDs ¶ added in v4.2.0
GetAll returns all entities in the repository
type PostgresRepository ¶
type PostgresRepository struct {
// contains filtered or unexported fields
}
PostgresRepository is a repository containing the Fact definition based on a PSQL database and implementing the repository interface
func (*PostgresRepository) Create ¶
func (r *PostgresRepository) Create(model modeler.Model) (int64, error)
Create creates a new model definition in the repository
func (*PostgresRepository) Delete ¶
func (r *PostgresRepository) Delete(id int64) error
Delete deletes a model from the repository by its name
func (*PostgresRepository) GetAll ¶
func (r *PostgresRepository) GetAll() (map[int64]modeler.Model, error)
GetAll returns all models in the repository
func (*PostgresRepository) GetAllByIDs ¶ added in v4.2.0
GetAll returns all models in the repository
type Repository ¶
type Repository interface { Get(id int64) (modeler.Model, bool, error) GetByName(name string) (modeler.Model, bool, error) Create(model modeler.Model) (int64, error) Update(id int64, situation modeler.Model) error Delete(id int64) error GetAll() (map[int64]modeler.Model, error) GetAllByIDs(ids []int64) (map[int64]modeler.Model, 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 situations
func NewNativeMapRepository ¶
func NewNativeMapRepository() Repository
NewNativeMapRepository returns a new instance of NativeMapRepository
func NewPostgresRepository ¶
func NewPostgresRepository(dbClient *sqlx.DB) Repository
NewPostgresRepository returns a new instance of PostgresRepository