-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathsql_table.go
More file actions
38 lines (34 loc) · 826 Bytes
/
sql_table.go
File metadata and controls
38 lines (34 loc) · 826 Bytes
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
package setup
type SQLTable struct {
Name string `json:"name"`
Engine string `json:"engine"`
Charset string `json:"charset"`
Definition string `json:"definition"`
Fields []*SQLField `json:"fields"`
Indexes []*SQLIndex `json:"indexes"`
Records []*SQLRecord `json:"records"`
}
func (this *SQLTable) FindField(fieldName string) *SQLField {
for _, field := range this.Fields {
if field.Name == fieldName {
return field
}
}
return nil
}
func (this *SQLTable) FindIndex(indexName string) *SQLIndex {
for _, index := range this.Indexes {
if index.Name == indexName {
return index
}
}
return nil
}
func (this *SQLTable) FindRecord(id int64) *SQLRecord {
for _, record := range this.Records {
if record.Id == id {
return record
}
}
return nil
}