-
Notifications
You must be signed in to change notification settings - Fork 0
/
datastore.go
52 lines (45 loc) · 1.35 KB
/
datastore.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
package ratatxt
// DatastoreCRUD provides basic datastore operation.
type DatastoreCRUD interface {
List(rows, filter interface{}) error
Get(row interface{}, id ID) error
Create(input interface{}) error
Update(input interface{}) error
Delete(input interface{}) error
}
// SearchOpts represent search options.
type SearchOpts struct {
Keyword string
KeywordFields []string
Filter interface{}
UserID ID
Page int
Limit int
IndexSorting bool
Sort string
Desc bool
}
// SearchMetadata represents search metadata.
type SearchMetadata struct {
ResultCount int
TotalCount int
}
// DatastoreSearch provides search datastore operation.
type DatastoreSearch interface {
Search(data interface{}, opts *SearchOpts) (*SearchMetadata, error)
Count(model interface{}, opts *SearchOpts) (int, error)
}
type DataStoreUtil interface {
AutoMigrate(obj ...interface{}) error
//AutoIndex(obj ...interface{}) error
}
// Datastore provides basic and search datastore operations.
type Datastore interface {
DatastoreSearch
DatastoreCRUD
DataStoreUtil
// MessageStats Custom operations
MessageStats(dst interface{}, scope StatsScope, filter *MessageFilter) error
MessageGraph(dst interface{}, scope StatsScope, filter *MessageFilter) error
OutboxGraph(dst interface{}, scope StatsScope, filter *MessageFilter) error
}