-
Notifications
You must be signed in to change notification settings - Fork 28
/
notification_gen.go
72 lines (60 loc) · 1.6 KB
/
notification_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 = &Notification{}
const NotificationTable = "notifications"
func (*Notification) LabelEntity() PostgresLabel {
return &NotificationLabel{}
}
func (*Notification) TableName() string {
return NotificationTable
}
func (e *Notification) NewLabel(id, key, value string) storage.Label {
now := pq.NullTime{
Time: time.Now(),
Valid: true,
}
return &NotificationLabel{
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,
},
NotificationID: sql.NullString{String: e.ID, Valid: e.ID != ""},
}
}
func (e *Notification) RowsToList(rows *sqlx.Rows) (types.ObjectList, error) {
rowCreator := func() EntityLabelRow {
return &struct {
*Notification
NotificationLabel `db:"notification_labels"`
}{}
}
result := &types.Notifications{
Notifications: make([]*types.Notification, 0),
}
err := rowsToList(rows, rowCreator, result)
if err != nil {
return nil, err
}
return result, nil
}
type NotificationLabel struct {
BaseLabelEntity
NotificationID sql.NullString `db:"notification_id"`
}
func (el NotificationLabel) LabelsTableName() string {
return "notification_labels"
}
func (el NotificationLabel) ReferenceColumn() string {
return "notification_id"
}