-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfilter.go
50 lines (41 loc) · 1.41 KB
/
filter.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
package lorm
import "github.com/tada-team/lorm/op"
type Filter interface {
Transactional
GetArgs() op.Args
GetConds() op.Conds
IsEmpty() bool
GetLock() op.Lock
GetOrderBy() op.Expr
GetLimit() int
GetOffset() int
}
type BaseFilter struct {
BaseTransactional
Conds op.Conds
Args op.Args
empty bool
limit int
offset int
lock op.Lock
orderBy op.Expr
}
func (f BaseFilter) GetArgs() op.Args { return f.Args }
func (f BaseFilter) GetConds() op.Conds { return f.Conds }
func (f BaseFilter) IsEmpty() bool { return f.empty }
func (f BaseFilter) GetLock() op.Lock { return f.lock }
func (f BaseFilter) GetOrderBy() op.Expr { return f.orderBy }
func (f BaseFilter) GetLimit() int { return f.limit }
func (f BaseFilter) GetOffset() int { return f.offset }
func (f *BaseFilter) SetOrderBy(v op.Expr) { f.orderBy = v }
func (f *BaseFilter) SetLimit(v int) { f.limit = v }
func (f *BaseFilter) SetOffset(v int) { f.offset = v }
func (f *BaseFilter) SetEmpty() { f.empty = true }
func (f *BaseFilter) SetLock(tx *Tx, lock op.Lock) { f.SetTx(tx); f.lock = lock }
// shortcuts
// C = condition
func (f *BaseFilter) C(v op.Expr) { f.Conds.Add(v) }
// N = next
func (f *BaseFilter) N(v interface{}) op.Placeholder { return f.Args.Next(v) }
// NA = next array
func (f *BaseFilter) NA(v interface{}) op.ArrayMask { return f.Args.NextArray(v) }