-
Notifications
You must be signed in to change notification settings - Fork 2
/
tables.go
117 lines (97 loc) · 3.34 KB
/
tables.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
// Code generated by qb-generator; DO NOT EDIT.
package mymodel
import "git.ultraware.nl/NiseVoid/qb"
///// Tables /////
var (
qbTablesTable = qb.Table{Name: `information_schema.tables`}
qbTablesFTableName = qb.TableField{Parent: &qbTablesTable, Name: `table_name`, ReadOnly: true}
qbTablesFTableSchema = qb.TableField{Parent: &qbTablesTable, Name: `table_schema`, ReadOnly: true}
)
// TablesType represents the table "Tables"
type TablesType struct {
TableName qb.Field
TableSchema qb.Field
table *qb.Table
}
// GetTable returns an object with info about the table
func (t *TablesType) GetTable() *qb.Table {
return t.table
}
// Select starts a SELECT query
func (t *TablesType) Select(f ...qb.Field) *qb.SelectBuilder {
return t.table.Select(f)
}
// Delete creates a DELETE query
func (t *TablesType) Delete(c1 qb.Condition, c ...qb.Condition) qb.Query {
return t.table.Delete(c1, c...)
}
// Update starts an UPDATE query
func (t *TablesType) Update() *qb.UpdateBuilder {
return t.table.Update()
}
// Insert starts an INSERT query
func (t *TablesType) Insert(f ...qb.Field) *qb.InsertBuilder {
return t.table.Insert(f)
}
// Tables returns a new TablesType
func Tables() *TablesType {
table := qbTablesTable
return &TablesType{
qbTablesFTableName.Copy(&table),
qbTablesFTableSchema.Copy(&table),
&table,
}
}
///// Columns /////
var (
qbColumnsTable = qb.Table{Name: `information_schema.columns`}
qbColumnsFColumnName = qb.TableField{Parent: &qbColumnsTable, Name: `column_name`, ReadOnly: true}
qbColumnsFDataType = qb.TableField{Parent: &qbColumnsTable, Name: `data_type`, ReadOnly: true}
qbColumnsFIsNullable = qb.TableField{Parent: &qbColumnsTable, Name: `is_nullable`, ReadOnly: true}
qbColumnsFCharacterMaximumLength = qb.TableField{Parent: &qbColumnsTable, Name: `character_maximum_length`, ReadOnly: true}
qbColumnsFTableSchema = qb.TableField{Parent: &qbColumnsTable, Name: `table_schema`, ReadOnly: true}
qbColumnsFTableName = qb.TableField{Parent: &qbColumnsTable, Name: `table_name`, ReadOnly: true}
)
// ColumnsType represents the table "Columns"
type ColumnsType struct {
ColumnName qb.Field
DataType qb.Field
IsNullable qb.Field
CharacterMaximumLength qb.Field
TableSchema qb.Field
TableName qb.Field
table *qb.Table
}
// GetTable returns an object with info about the table
func (t *ColumnsType) GetTable() *qb.Table {
return t.table
}
// Select starts a SELECT query
func (t *ColumnsType) Select(f ...qb.Field) *qb.SelectBuilder {
return t.table.Select(f)
}
// Delete creates a DELETE query
func (t *ColumnsType) Delete(c1 qb.Condition, c ...qb.Condition) qb.Query {
return t.table.Delete(c1, c...)
}
// Update starts an UPDATE query
func (t *ColumnsType) Update() *qb.UpdateBuilder {
return t.table.Update()
}
// Insert starts an INSERT query
func (t *ColumnsType) Insert(f ...qb.Field) *qb.InsertBuilder {
return t.table.Insert(f)
}
// Columns returns a new ColumnsType
func Columns() *ColumnsType {
table := qbColumnsTable
return &ColumnsType{
qbColumnsFColumnName.Copy(&table),
qbColumnsFDataType.Copy(&table),
qbColumnsFIsNullable.Copy(&table),
qbColumnsFCharacterMaximumLength.Copy(&table),
qbColumnsFTableSchema.Copy(&table),
qbColumnsFTableName.Copy(&table),
&table,
}
}