Merge pull request #1 from cbandy/canned-queries
Expose all constant queries as Client functions
This commit is contained in:
commit
5164d5946e
4
api.go
4
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))
|
||||
|
@ -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))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user