Move table schema query into client
This commit is contained in:
2
api.go
2
api.go
@@ -79,7 +79,7 @@ func API_GetTables(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func API_GetTable(c *gin.Context) {
|
func API_GetTable(c *gin.Context) {
|
||||||
res, err := dbClient.Query(fmt.Sprintf(PG_TABLE_SCHEMA, c.Params.ByName("table")))
|
res, err := dbClient.Table(c.Params.ByName("table"))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, NewError(err))
|
c.JSON(400, NewError(err))
|
||||||
|
|||||||
@@ -80,6 +80,10 @@ func (client *Client) Tables() ([]string, error) {
|
|||||||
return tables, nil
|
return tables, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (client *Client) Table(table string) (*Result, error) {
|
||||||
|
return client.Query(fmt.Sprintf(PG_TABLE_SCHEMA, table))
|
||||||
|
}
|
||||||
|
|
||||||
func (client *Client) TableIndexes(table string) (*Result, error) {
|
func (client *Client) TableIndexes(table string) (*Result, error) {
|
||||||
res, err := client.Query(fmt.Sprintf(PG_TABLE_INDEXES, table))
|
res, err := client.Query(fmt.Sprintf(PG_TABLE_INDEXES, table))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user