-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.go
72 lines (56 loc) · 1.07 KB
/
list.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
package ldb
import (
sqlg "github.com/mzahradnicek/sql-glue"
)
type List struct {
Total int `json:"total"`
Limit int `json:"limit"`
Offset int `json:"offset"`
conn *Connection
opt *QueryOptions
params QueryParams
where *sqlg.Qg // DEPRECATED
filter sqlg.Qg
}
func (l *List) SetConnection(conn *Connection) {
l.conn = conn
}
func (l List) Conn() *Connection {
return l.conn
}
func (l *List) SetFilter(qg sqlg.Qg) {
l.filter = qg
}
func (l List) GetFilter() sqlg.Qg {
return l.filter
}
func (l *List) SetParams(p QueryParams) {
l.params = p
}
func (l List) GetParams() QueryParams {
return l.params
}
// DEPRECATED
func (l *List) SetWhere(qg *sqlg.Qg) {
l.where = qg
}
// DEPRECATED
func (l List) GetWhere() *sqlg.Qg {
return l.where
}
func (l *List) QueryOptions(opt QueryOptions) {
l.opt = &opt
}
func (l *List) ApplyQueryOptions(q *sqlg.Qg) {
if l.opt == nil {
return
}
l.opt.ApplyToQuery(q)
l.Limit = l.opt.Limit
l.Offset = l.opt.Offset
}
func NewList(conn *Connection) *List {
res := &List{conn: conn}
res.params = make(QueryParams)
return res
}