The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
grafana/pkg/stores/sqlstore/sqlstore_accounts.go

56 lines
954 B

package sqlstore
import (
"github.com/torkelo/grafana-pro/pkg/models"
)
func CreateAccount(account *models.Account) error {
var err error
sess := x.NewSession()
defer sess.Close()
if err = sess.Begin(); err != nil {
return err
}
if _, err = sess.Insert(account); err != nil {
sess.Rollback()
return err
} else if err = sess.Commit(); err != nil {
return err
}
return nil
}
func GetAccount(id int64) (*models.Account, error) {
var err error
account := &models.Account{Id: id}
has, err := x.Get(account)
if err != nil {
return nil, err
} else if has == false {
return nil, models.ErrAccountNotFound
}
return account, nil
}
func GetAccountByLogin(emailOrLogin string) (*models.Account, error) {
var err error
account := &models.Account{Login: emailOrLogin}
has, err := x.Get(account)
if err != nil {
return nil, err
} else if has == false {
return nil, models.ErrAccountNotFound
}
return account, nil
}