-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyautoincrement.xo.go
44 lines (35 loc) · 926 Bytes
/
myautoincrement.xo.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
// Package models contains the types for schema 'xodb'.
package models
// Code generated by xo. DO NOT EDIT.
// MyAutoIncrement represents a row from '[custom my_auto_increment]'.
type MyAutoIncrement struct {
TableName string // table_name
}
// MyAutoIncrements runs a custom query, returning results as MyAutoIncrement.
func MyAutoIncrements(db XODB, schema string) ([]*MyAutoIncrement, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`table_name ` +
`FROM information_schema.tables ` +
`WHERE auto_increment IS NOT null AND table_schema = ?`
// run query
XOLog(sqlstr, schema)
q, err := db.Query(sqlstr, schema)
if err != nil {
return nil, err
}
defer q.Close()
// load results
res := []*MyAutoIncrement{}
for q.Next() {
mai := MyAutoIncrement{}
// scan
err = q.Scan(&mai.TableName)
if err != nil {
return nil, err
}
res = append(res, &mai)
}
return res, nil
}