forked from Zenithar/go-common
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default_crud.go
119 lines (96 loc) · 3.38 KB
/
default_crud.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package mock
import "zenithar.org/go/common/dao/api"
// Default contains the basic implementation of the EntityCRUD interface
type Default struct {
table string
db string
session interface{}
}
// NewCRUDTable sets up a new Default struct
func NewCRUDTable(session interface{}, db, table string) *Default {
return &Default{
db: db,
table: table,
session: session,
}
}
// GetTableName returns table's name
func (d *Default) GetTableName() string {
return d.table
}
// GetDBName returns database's name
func (d *Default) GetDBName() string {
return d.db
}
// GetTable returns no table
func (d *Default) GetTable() interface{} {
return nil
}
// GetSession returns the current session
func (d *Default) GetSession() interface{} {
return nil
}
// Insert inserts a document into the database
func (d *Default) Insert(data interface{}) error {
return api.ErrNotImplemented
}
// InsertOrUpdate a document occording to ID presence in database
func (d *Default) InsertOrUpdate(id interface{}, data interface{}) error {
return api.ErrNotImplemented
}
// Find a document match given id
func (d *Default) Find(id interface{}, value interface{}) error {
return api.ErrNotImplemented
}
// FindOneBy a couple (k = v) in the database
func (d *Default) FindOneBy(key string, value interface{}, result interface{}) error {
return api.ErrNotImplemented
}
// FindBy a couple (k = v) in the database
func (d *Default) FindBy(key string, value interface{}, results interface{}) error {
return api.ErrNotImplemented
}
// FindByAndCount is used to count object that matchs the (key = value) predicate
func (d *Default) FindByAndCount(key string, value interface{}) (int, error) {
return -1, api.ErrNotImplemented
}
// Where is used to fetch documents that match th filter from the database
func (d *Default) Where(filter map[string]interface{}, results interface{}) error {
return api.ErrNotImplemented
}
// WhereCount returns the document count that match the filter
func (d *Default) WhereCount(filter map[string]interface{}) (int, error) {
return -1, api.ErrNotImplemented
}
// WhereAndFetchOne returns one document that match the filter
func (d *Default) WhereAndFetchOne(filter map[string]interface{}, result interface{}) error {
return api.ErrNotImplemented
}
// WhereAndFetchLimit returns paginated list of document
func (d *Default) WhereAndFetchLimit(filter map[string]interface{}, paginator *api.Pagination, results interface{}) error {
return api.ErrNotImplemented
}
// Update a document that match the selector
func (d *Default) Update(selector interface{}, data interface{}) error {
return api.ErrNotImplemented
}
// UpdateID updates a document using his id
func (d *Default) UpdateID(id interface{}, data interface{}) error {
return api.ErrNotImplemented
}
// DeleteAll documents from the database
func (d *Default) DeleteAll(pred interface{}) error {
return api.ErrNotImplemented
}
// Delete a document from the database
func (d *Default) Delete(id interface{}) error {
return api.ErrNotImplemented
}
// List all entities from the database
func (d *Default) List(results interface{}, sortParams *api.SortParameters, pagination *api.Pagination) error {
return api.ErrNotImplemented
}
// Search all entities from the database
func (d *Default) Search(results interface{}, filter map[string]interface{}, sortParams *api.SortParameters, pagination *api.Pagination) error {
return api.ErrNotImplemented
}