Small progress, save search works
This commit is contained in:
@@ -14,7 +14,13 @@ func SaveDashboard(dash *models.Dashboard) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err = sess.Insert(dash); err != nil {
|
||||
if dash.Id == 0 {
|
||||
_, err = sess.Insert(dash)
|
||||
} else {
|
||||
_, err = sess.Update(dash)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
sess.Rollback()
|
||||
return err
|
||||
} else if err = sess.Commit(); err != nil {
|
||||
@@ -36,3 +42,13 @@ func GetDashboard(slug string, accountId int64) (*models.Dashboard, error) {
|
||||
|
||||
return &dashboard, nil
|
||||
}
|
||||
|
||||
func SearchQuery(query string, accountId int64) ([]*models.SearchResult, error) {
|
||||
sess := x.Limit(100, 0).Where("account_id=?", accountId)
|
||||
sess.Table("Dashboard")
|
||||
|
||||
var results []*models.SearchResult
|
||||
err := sess.Find(&results)
|
||||
|
||||
return results, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user