Files
go-zero/tools/goctl/model/sql/model/informationschemamodel.go
Keson c9494c8bc7 model support globbing patterns (#153)
* model support globbing patterns

* optimize model

* optimize model

* format code
2020-10-22 18:33:09 +08:00

26 lines
544 B
Go

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
}