model support globbing patterns (#153)

* model support globbing patterns

* optimize model

* optimize model

* format code
This commit is contained in:
Keson
2020-10-22 18:33:09 +08:00
committed by GitHub
parent 1fd2ef9347
commit c9494c8bc7
20 changed files with 258 additions and 44 deletions

View File

@@ -0,0 +1,25 @@
package model
import (
"github.com/tal-tech/go-zero/core/stores/sqlx"
)
type (
InformationSchemaModel struct {
conn sqlx.SqlConn
}
)
func NewInformationSchemaModel(conn sqlx.SqlConn) *InformationSchemaModel {
return &InformationSchemaModel{conn: conn}
}
func (m *InformationSchemaModel) GetAllTables(database string) ([]string, error) {
query := `select TABLE_NAME from TABLES where TABLE_SCHEMA = ?`
var tables []string
err := m.conn.QueryRows(&tables, query, database)
if err != nil {
return nil, err
}
return tables, nil
}