-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwhere_factory.go
44 lines (36 loc) · 892 Bytes
/
where_factory.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
package querybuilder
type WhereFactory struct {
modifier Modifier
}
func NewWF(modifier Modifier) *WhereFactory {
return &WhereFactory{modifier}
}
func (factory *WhereFactory) New(args []interface{}) Where {
length := len(args)
condi := []interface{}{}
switch length {
case 2:
condi = []interface{}{args[0], "=", args[1]}
case 3:
condi = args
}
where := NewW(factory.modifier)
where.Field = condi[0].(string)
where.Op = condi[1].(string)
where.Value = condi[2]
return where
}
func (factory *WhereFactory) NewQuery(field string, op string, other *Builder) Where {
where := NewW(factory.modifier)
where.Field = field
where.Op = op
where.Query = other
return where
}
func (factory *WhereFactory) NewArray(field string, op string, array []interface{}) Where {
where := NewW(factory.modifier)
where.Field = field
where.Op = op
where.Array = array
return where
}