This repository was archived by the owner on Sep 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathdatabase.go
More file actions
39 lines (34 loc) · 1.38 KB
/
database.go
File metadata and controls
39 lines (34 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package api
import (
"github.com/pkg/errors"
)
// DatabaseErrorNotFound is an error that indicates that the function failed because
// the seach returned zero results. It is expected to be returned by Select et al.
type DatabaseErrorNotFound string
func (d DatabaseErrorNotFound) Error() string {
return string(d)
}
// IsDatabaseErrorNotFound returns true if the error is a DatabaseErrorNotFound error
func IsDatabaseErrorNotFound(err error) bool {
if _, ok := errors.Cause(err).(DatabaseErrorNotFound); ok {
return true
}
return false
}
// DatabaseService represents a persisted data storage.
type DatabaseService interface {
Raw(query interface{}, params ...interface{}) error
Find(query interface{}, callback func(query interface{}))
FindAll(model interface{}) error
Where(model interface{}, condition string, params ...interface{}) error
ColumnsWhere(model interface{}, columns []string, condition string, params ...interface{}) error
Insert(query ...interface{}) error
Update(query interface{}) error
Save(query ...interface{}) error
Delete(query interface{}) error
Select(query interface{}) error
Count(model interface{}, condition string, params ...interface{}) int
CountExpr(model interface{}, expr string, retval interface{}, condition string, params ...interface{})
Array(model interface{}, expr string, retval interface{}, condition string, params ...interface{})
Close() error
}