-
Notifications
You must be signed in to change notification settings - Fork 28
/
visibility_gen.go
72 lines (60 loc) · 1.56 KB
/
visibility_gen.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
// GENERATED. DO NOT MODIFY!
package postgres
import (
"github.com/Peripli/service-manager/pkg/types"
"github.com/Peripli/service-manager/storage"
"github.com/jmoiron/sqlx"
"github.com/lib/pq"
"database/sql"
"time"
)
var _ PostgresEntity = &Visibility{}
const VisibilityTable = "visibilities"
func (*Visibility) LabelEntity() PostgresLabel {
return &VisibilityLabel{}
}
func (*Visibility) TableName() string {
return VisibilityTable
}
func (e *Visibility) NewLabel(id, key, value string) storage.Label {
now := pq.NullTime{
Time: time.Now(),
Valid: true,
}
return &VisibilityLabel{
BaseLabelEntity: BaseLabelEntity{
ID: sql.NullString{String: id, Valid: id != ""},
Key: sql.NullString{String: key, Valid: key != ""},
Val: sql.NullString{String: value, Valid: value != ""},
CreatedAt: now,
UpdatedAt: now,
},
VisibilityID: sql.NullString{String: e.ID, Valid: e.ID != ""},
}
}
func (e *Visibility) RowsToList(rows *sqlx.Rows) (types.ObjectList, error) {
rowCreator := func() EntityLabelRow {
return &struct {
*Visibility
VisibilityLabel `db:"visibility_labels"`
}{}
}
result := &types.Visibilities{
Visibilities: make([]*types.Visibility, 0),
}
err := rowsToList(rows, rowCreator, result)
if err != nil {
return nil, err
}
return result, nil
}
type VisibilityLabel struct {
BaseLabelEntity
VisibilityID sql.NullString `db:"visibility_id"`
}
func (el VisibilityLabel) LabelsTableName() string {
return "visibility_labels"
}
func (el VisibilityLabel) ReferenceColumn() string {
return "visibility_id"
}