forked from pydio/config-srv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.go
55 lines (42 loc) · 1.06 KB
/
db.go
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package db
import (
"errors"
proto "github.com/pydio/config-srv/proto/config"
)
type DB interface {
Init() error
Create(*proto.Change) error
Read(id string) (*proto.Change, error)
Update(*proto.Change) error
Delete(*proto.Change) error
Search(id, author string, limit, offset int64) ([]*proto.Change, error)
AuditLog(from, to int64, limit, offset int64, reverse bool) ([]*proto.ChangeLog, error)
}
var (
db DB
ErrNotFound = errors.New("not found")
)
func Register(backend DB) {
db = backend
}
func Init() error {
return db.Init()
}
func Create(ch *proto.Change) error {
return db.Create(ch)
}
func Read(id string) (*proto.Change, error) {
return db.Read(id)
}
func Update(ch *proto.Change) error {
return db.Update(ch)
}
func Delete(ch *proto.Change) error {
return db.Delete(ch)
}
func Search(id, author string, limit, offset int64) ([]*proto.Change, error) {
return db.Search(id, author, limit, offset)
}
func AuditLog(from, to, limit, offset int64, reverse bool) ([]*proto.ChangeLog, error) {
return db.AuditLog(from, to, limit, offset, reverse)
}