Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrRecordNotFound = errors.New("record not in the database")
)
Functions ¶
This section is empty.
Types ¶
type Storage ¶ added in v1.4.0
type Storage interface {
// Create creates a new object and put it into the DB
Create(r interface{}) error
// Save updates the record r (workaround with conds needed that e.g. user has no specific ID, and we can not touch
// the generated (gRPC) code s.t. user.username has primary key annotation)
Save(r interface{}, conds ...interface{}) error
// Update updates the record with given id of the DB with non-zero values in r
Update(r interface{}, query interface{}, args ...interface{}) error
// Get gets the record which meet the given conditions
Get(r interface{}, conds ...interface{}) error
// List lists all records in database which meet the (optionally) given conditions with a certain limit after an
// offset. If no limit is desired, the value -1 can be specified
List(r interface{}, offset int, limit int, conds ...interface{}) error
// Count counts the number of records which meet the (optionally) given conditions
Count(r interface{}, conds ...interface{}) (int64, error)
// Delete deletes the record with given id of the DB
Delete(r interface{}, conds ...interface{}) error
}
Storage comprises a database interface TODO(all): I think with generics we could get sth. like `[T]Get(r T, id string) T` which is maybe more intuitive then changing the parameter? Maybe its only my impression
Click to show internal directories.
Click to hide internal directories.