This repository has been archived by the owner on Jun 21, 2022. It is now read-only.
/
job_models_reform.go
166 lines (144 loc) · 4.25 KB
/
job_models_reform.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
// Code generated by gopkg.in/reform.v1. DO NOT EDIT.
package models
import (
"fmt"
"strings"
"gopkg.in/reform.v1"
"gopkg.in/reform.v1/parse"
)
type jobResultTableType struct {
s parse.StructInfo
z []interface{}
}
// Schema returns a schema name in SQL database ("").
func (v *jobResultTableType) Schema() string {
return v.s.SQLSchema
}
// Name returns a view or table name in SQL database ("job_results").
func (v *jobResultTableType) Name() string {
return v.s.SQLName
}
// Columns returns a new slice of column names for that view or table in SQL database.
func (v *jobResultTableType) Columns() []string {
return []string{
"id",
"pmm_agent_id",
"type",
"done",
"error",
"result",
"created_at",
"updated_at",
}
}
// NewStruct makes a new struct for that view or table.
func (v *jobResultTableType) NewStruct() reform.Struct {
return new(JobResult)
}
// NewRecord makes a new record for that table.
func (v *jobResultTableType) NewRecord() reform.Record {
return new(JobResult)
}
// PKColumnIndex returns an index of primary key column for that table in SQL database.
func (v *jobResultTableType) PKColumnIndex() uint {
return uint(v.s.PKFieldIndex)
}
// JobResultTable represents job_results view or table in SQL database.
var JobResultTable = &jobResultTableType{
s: parse.StructInfo{
Type: "JobResult",
SQLName: "job_results",
Fields: []parse.FieldInfo{
{Name: "ID", Type: "string", Column: "id"},
{Name: "PMMAgentID", Type: "string", Column: "pmm_agent_id"},
{Name: "Type", Type: "JobType", Column: "type"},
{Name: "Done", Type: "bool", Column: "done"},
{Name: "Error", Type: "string", Column: "error"},
{Name: "Result", Type: "*JobResultData", Column: "result"},
{Name: "CreatedAt", Type: "time.Time", Column: "created_at"},
{Name: "UpdatedAt", Type: "time.Time", Column: "updated_at"},
},
PKFieldIndex: 0,
},
z: new(JobResult).Values(),
}
// String returns a string representation of this struct or record.
func (s JobResult) String() string {
res := make([]string, 8)
res[0] = "ID: " + reform.Inspect(s.ID, true)
res[1] = "PMMAgentID: " + reform.Inspect(s.PMMAgentID, true)
res[2] = "Type: " + reform.Inspect(s.Type, true)
res[3] = "Done: " + reform.Inspect(s.Done, true)
res[4] = "Error: " + reform.Inspect(s.Error, true)
res[5] = "Result: " + reform.Inspect(s.Result, true)
res[6] = "CreatedAt: " + reform.Inspect(s.CreatedAt, true)
res[7] = "UpdatedAt: " + reform.Inspect(s.UpdatedAt, true)
return strings.Join(res, ", ")
}
// Values returns a slice of struct or record field values.
// Returned interface{} values are never untyped nils.
func (s *JobResult) Values() []interface{} {
return []interface{}{
s.ID,
s.PMMAgentID,
s.Type,
s.Done,
s.Error,
s.Result,
s.CreatedAt,
s.UpdatedAt,
}
}
// Pointers returns a slice of pointers to struct or record fields.
// Returned interface{} values are never untyped nils.
func (s *JobResult) Pointers() []interface{} {
return []interface{}{
&s.ID,
&s.PMMAgentID,
&s.Type,
&s.Done,
&s.Error,
&s.Result,
&s.CreatedAt,
&s.UpdatedAt,
}
}
// View returns View object for that struct.
func (s *JobResult) View() reform.View {
return JobResultTable
}
// Table returns Table object for that record.
func (s *JobResult) Table() reform.Table {
return JobResultTable
}
// PKValue returns a value of primary key for that record.
// Returned interface{} value is never untyped nil.
func (s *JobResult) PKValue() interface{} {
return s.ID
}
// PKPointer returns a pointer to primary key field for that record.
// Returned interface{} value is never untyped nil.
func (s *JobResult) PKPointer() interface{} {
return &s.ID
}
// HasPK returns true if record has non-zero primary key set, false otherwise.
func (s *JobResult) HasPK() bool {
return s.ID != JobResultTable.z[JobResultTable.s.PKFieldIndex]
}
// SetPK sets record primary key, if possible.
//
// Deprecated: prefer direct field assignment where possible: s.ID = pk.
func (s *JobResult) SetPK(pk interface{}) {
reform.SetPK(s, pk)
}
// check interfaces
var (
_ reform.View = JobResultTable
_ reform.Struct = (*JobResult)(nil)
_ reform.Table = JobResultTable
_ reform.Record = (*JobResult)(nil)
_ fmt.Stringer = (*JobResult)(nil)
)
func init() {
parse.AssertUpToDate(&JobResultTable.s, new(JobResult))
}