-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsqautoincrement.xo.go
46 lines (37 loc) · 913 Bytes
/
sqautoincrement.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
45
46
// Package models contains the types for schema ''.
package models
// Code generated by xo. DO NOT EDIT.
// SqAutoIncrement represents a row from '[custom sq_auto_increment]'.
type SqAutoIncrement struct {
TableName string // table_name
SQL string // sql
}
// SqAutoIncrements runs a custom query, returning results as SqAutoIncrement.
func SqAutoIncrements(db XODB) ([]*SqAutoIncrement, error) {
var err error
// sql query
const sqlstr = `SELECT ` +
`name as table_name, sql ` +
`FROM sqlite_master ` +
`WHERE type='table' ` +
`ORDER BY name`
// run query
XOLog(sqlstr)
q, err := db.Query(sqlstr)
if err != nil {
return nil, err
}
defer q.Close()
// load results
res := []*SqAutoIncrement{}
for q.Next() {
sai := SqAutoIncrement{}
// scan
err = q.Scan(&sai.TableName, &sai.SQL)
if err != nil {
return nil, err
}
res = append(res, &sai)
}
return res, nil
}