diff --git a/api.go b/api.go index 272b967..33e5aa8 100644 --- a/api.go +++ b/api.go @@ -79,7 +79,7 @@ func API_GetTables(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 { c.JSON(400, NewError(err)) @@ -94,7 +94,7 @@ func API_History(c *gin.Context) { } func API_Info(c *gin.Context) { - res, err := dbClient.Query(PG_INFO) + res, err := dbClient.Info() if err != nil { c.JSON(400, NewError(err)) diff --git a/client.go b/client.go index 6b89775..97d1b6a 100644 --- a/client.go +++ b/client.go @@ -48,6 +48,10 @@ func (client *Client) recordQuery(query string) { client.history = append(client.history, query) } +func (client *Client) Info() (*Result, error) { + return client.Query(PG_INFO) +} + func (client *Client) Databases() ([]string, error) { res, err := client.Query(PG_DATABASES) @@ -80,6 +84,10 @@ func (client *Client) Tables() ([]string, error) { 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) { res, err := client.Query(fmt.Sprintf(PG_TABLE_INDEXES, table))