forked from rainycape/gondola
-
Notifications
You must be signed in to change notification settings - Fork 0
/
q.go
115 lines (99 loc) · 2.22 KB
/
q.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
package orm
import (
"gnd.la/orm/query"
)
func Eq(field string, value interface{}) query.Q {
return &query.Eq{
Field: query.Field{
Field: field,
Value: value,
},
}
}
func Neq(field string, value interface{}) query.Q {
return &query.Neq{
Field: query.Field{
Field: field,
Value: value,
},
}
}
func Contains(field string, value interface{}) query.Q {
return &query.Contains{
Field: query.Field{
Field: field,
Value: value,
},
}
}
func Lt(field string, value interface{}) query.Q {
return &query.Lt{
Field: query.Field{
Field: field,
Value: value,
},
}
}
func Lte(field string, value interface{}) query.Q {
return &query.Lte{
Field: query.Field{
Field: field,
Value: value,
},
}
}
func Gt(field string, value interface{}) query.Q {
return &query.Gt{
Field: query.Field{
Field: field,
Value: value,
},
}
}
func Gte(field string, value interface{}) query.Q {
return &query.Gte{
Field: query.Field{
Field: field,
Value: value,
},
}
}
func In(field string, value interface{}) query.Q {
return &query.In{
Field: query.Field{
Field: field,
Value: value,
},
}
}
func And(qs ...query.Q) query.Q {
return &query.And{
Combinator: query.Combinator{
Conditions: qs,
},
}
}
func Or(qs ...query.Q) query.Q {
return &query.Or{
Combinator: query.Combinator{
Conditions: qs,
},
}
}
// These are shorthand forms for the previous
// Between is equivalent to field > begin AND field < end.
func Between(field string, begin interface{}, end interface{}) query.Q {
return And(Gt(field, begin), Lt(field, end))
}
// CBetween stands for closed between and is equivalent to field >= begin AND field <= end.
func CBetween(field string, begin interface{}, end interface{}) query.Q {
return And(Gte(field, begin), Lte(field, end))
}
// LCBetween stands for left closed between and is equivalent to field >= begin AND field < end.
func LCBetween(field string, begin interface{}, end interface{}) query.Q {
return And(Gte(field, begin), Lt(field, end))
}
// RCBetween stands for right closed between and is equivalent to field > begin AND field <= end.
func RCBetween(field string, begin interface{}, end interface{}) query.Q {
return And(Gt(field, begin), Lte(field, end))
}