-
Notifications
You must be signed in to change notification settings - Fork 3
/
meta.go
64 lines (51 loc) · 1.32 KB
/
meta.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
package deltas
import "github.com/beaconsoftwarellc/gadget/v2/database/qb"
type deltaMeta struct {
alias string
ID qb.TableField
Name qb.TableField
Created qb.TableField
Modified qb.TableField
allColumns qb.TableField
}
func (p *deltaMeta) AllColumns() qb.TableField {
return p.allColumns
}
func (p *deltaMeta) GetName() string {
return "delta"
}
func (p *deltaMeta) GetAlias() string {
return p.alias
}
func (p *deltaMeta) PrimaryKey() qb.TableField {
return p.ID
}
func (p *deltaMeta) SortBy() (qb.TableField, qb.OrderDirection) {
return p.Created, qb.Ascending
}
func (p *deltaMeta) ReadColumns() []qb.TableField {
return []qb.TableField{
p.ID,
p.Name,
p.Created,
p.Modified,
}
}
func (p *deltaMeta) WriteColumns() []qb.TableField {
return []qb.TableField{
p.ID,
p.Name,
}
}
func (p *deltaMeta) Alias(alias string) *deltaMeta {
return &deltaMeta{
alias: alias,
ID: qb.TableField{Name: "id", Table: alias},
Name: qb.TableField{Name: "name", Table: alias},
Created: qb.TableField{Name: "created", Table: alias},
Modified: qb.TableField{Name: "modified", Table: alias},
allColumns: qb.TableField{Name: "*", Table: alias},
}
}
// DeltaMeta is a meta representation of the database delta table for building ad hoc queries
var DeltaMeta = (&deltaMeta{}).Alias("delta")