change docstring formating
This commit is contained in:
@@ -7,10 +7,10 @@ import (
|
||||
)
|
||||
|
||||
|
||||
// An interface to manage generic structure objects persistently. Should use an
|
||||
// IDatastore as the interface that actually stores and retrieves the data from
|
||||
// an external source.
|
||||
type IRepository[T IIdentifiable] interface {
|
||||
/* An interface to manage generic structure objects persistently. Should
|
||||
* use an IDatastore as the interface that actually stores and retrieves the
|
||||
* data from an external source. */
|
||||
Create(t T) error
|
||||
Update(t T) error
|
||||
Delete(t T) error
|
||||
@@ -19,6 +19,7 @@ type IRepository[T IIdentifiable] interface {
|
||||
GetByCriteria(c ISearchCriteria[T]) ([]T, error)
|
||||
}
|
||||
|
||||
|
||||
// --- default implementation ---
|
||||
|
||||
type DefaultRepository[T IIdentifiable] struct {
|
||||
@@ -30,10 +31,10 @@ func NewDefaultRepository[T IIdentifiable](ds IDatastore, prefix string) *Defaul
|
||||
return &DefaultRepository[T]{ ds: ds, prefix: prefix }
|
||||
}
|
||||
|
||||
// Creates a new entry in the repository with the given object t. Throws an
|
||||
// error if there already exists an entry with the same id, the json encoding
|
||||
// fails or the connection to the IDatastore fails.
|
||||
func (repo *DefaultRepository[T]) Create(t T) error {
|
||||
/* Creates a new entry in the repository with the given object t. Throws an
|
||||
* error if there already exists an entry with the same id, the json
|
||||
* encoding fails or the connection to the IDatastore fails. */
|
||||
|
||||
key := repo.prefix + ":" + strconv.FormatUint(uint64(t.Id()), 10)
|
||||
exists, err := repo.ds.KeyExists(key)
|
||||
@@ -49,10 +50,10 @@ func (repo *DefaultRepository[T]) Create(t T) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Updates the entry with the same id as t in the repository with the values of
|
||||
// t. Trows an error if the json encoding fails or the connection to the
|
||||
// IDatastore fails.
|
||||
func (repo *DefaultRepository[T]) Update(t T) error {
|
||||
/* Updates the entry with the same id as t in the repository with the
|
||||
* values of t. Trows an error if the json encoding fails or the connection
|
||||
* to the IDatastore fails. */
|
||||
|
||||
key := repo.prefix + ":" + strconv.FormatUint(uint64(t.Id()), 10)
|
||||
exists, err := repo.ds.KeyExists(key)
|
||||
|
||||
Reference in New Issue
Block a user