Add Sequences to API.

This commit is contained in:
niiyz 2015-11-13 21:36:13 +09:00
parent 4c1bb758ce
commit 232790b452
4 changed files with 12 additions and 0 deletions

View File

@ -164,6 +164,11 @@ func GetConnectionInfo(c *gin.Context) {
c.JSON(200, res.Format()[0])
}
func GetSequences(c *gin.Context) {
res, err := DbClient.Sequences()
serveResult(res, err, c)
}
func GetActivity(c *gin.Context) {
res, err := DbClient.Activity()
serveResult(res, err, c)

View File

@ -25,6 +25,7 @@ func SetupRoutes(router *gin.Engine) {
api.POST("/connect", Connect)
api.GET("/databases", GetDatabases)
api.GET("/connection", GetConnectionInfo)
api.GET("/sequences", GetSequences)
api.GET("/activity", GetActivity)
api.GET("/schemas", GetSchemas)
api.GET("/tables", GetTables)

View File

@ -136,6 +136,10 @@ func (client *Client) TableIndexes(table string) (*Result, error) {
return res, err
}
func (client *Client) Sequences() ([]string, error) {
return client.fetchRows(statements.PG_SEQUENCES)
}
// Returns all active queriers on the server
func (client *Client) Activity() (*Result, error) {
return client.query(statements.PG_ACTIVITY)

View File

@ -31,6 +31,8 @@ WHERE table_name = $1`
PG_TABLES = `SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' ORDER BY table_schema,table_name`
PG_SEQUENCES = `SELECT sequence_name FROM information_schema.sequences WHERE sequence_schema = 'public' ORDER BY sequence_name`
PG_ACTIVITY = `SELECT
datname,
query,