From 42f79a707944fc147d02ec7dc4d791e909b08455 Mon Sep 17 00:00:00 2001 From: Chris Bandy Date: Thu, 16 Oct 2014 02:54:40 +0000 Subject: [PATCH] Move table schema query into client --- api.go | 2 +- client.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/api.go b/api.go index 272b967..714a6f1 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)) diff --git a/client.go b/client.go index 6b89775..9a056f4 100644 --- a/client.go +++ b/client.go @@ -80,6 +80,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))