CLI: Add datasource:info command

Describes the full datasource details given an account and
datasource name.
This commit is contained in:
Jason Wilder
2015-02-15 13:36:10 -07:00
parent 9cb1170361
commit f443b7087c
4 changed files with 75 additions and 7 deletions
+11
View File
@@ -15,6 +15,7 @@ func init() {
bus.AddHandler("sql", DeleteDataSource)
bus.AddHandler("sql", UpdateDataSource)
bus.AddHandler("sql", GetDataSourceById)
bus.AddHandler("sql", GetDataSourceByName)
}
func GetDataSourceById(query *m.GetDataSourceByIdQuery) error {
@@ -27,6 +28,16 @@ func GetDataSourceById(query *m.GetDataSourceByIdQuery) error {
return err
}
func GetDataSourceByName(query *m.GetDataSourceByNameQuery) error {
sess := x.Limit(100, 0).Where("account_id=? AND name=?", query.AccountId, query.Name)
has, err := sess.Get(&query.Result)
if !has {
return m.ErrDataSourceNotFound
}
return err
}
func GetDataSources(query *m.GetDataSourcesQuery) error {
sess := x.Limit(100, 0).Where("account_id=?", query.AccountId).Asc("name")