-
Notifications
You must be signed in to change notification settings - Fork 0
/
subject.go
67 lines (53 loc) · 1.46 KB
/
subject.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
package query
type Subject struct {
keywords []string
sortable bool
}
func (s *Subject) Keywords() []string {
return s.keywords
}
func (s *Subject) Sortable() bool {
return s.sortable
}
func (s *Subject) Name() string {
return s.keywords[0]
}
func (s Subject) String() string {
return s.keywords[0]
}
var (
SubjectFind = &Subject{keywords: []string{"Find", "Query", "Get", "Search"}, sortable: true}
SubjectCount = &Subject{keywords: []string{"Count"}, sortable: false}
SubjectExists = &Subject{keywords: []string{"Exists"}, sortable: false}
SubjectDelete = &Subject{keywords: []string{"Delete", "Remove"}, sortable: true}
)
var Subjects = []*Subject{
SubjectFind, SubjectCount, SubjectExists, SubjectDelete,
}
type SubjectModifier struct {
keywords []string
subjects map[*Subject]bool //the modifier supported Subject
}
func (s *SubjectModifier) Keywords() []string {
return s.keywords
}
func (s *SubjectModifier) Subjects() map[*Subject]bool {
return s.subjects
}
func (s SubjectModifier) String() string {
return s.keywords[0]
}
var (
SubjectModifierDistinct = &SubjectModifier{
keywords: []string{"Distinct"},
subjects: map[*Subject]bool{SubjectFind: true, SubjectCount: true},
}
SubjectModifierTop = &SubjectModifier{
keywords: []string{"Top"},
subjects: map[*Subject]bool{SubjectFind: true, SubjectDelete: true},
}
)
var SubjectModifiers = []*SubjectModifier{
SubjectModifierDistinct, SubjectModifierTop,
}
type SubjectModifierArg string