2021-08-24 05:28:09 -05:00
|
|
|
package store
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2022-10-19 08:02:15 -05:00
|
|
|
"github.com/grafana/grafana/pkg/infra/db"
|
2021-08-24 05:28:09 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
type OrgStore interface {
|
|
|
|
GetOrgs(ctx context.Context) ([]int64, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (st DBstore) GetOrgs(ctx context.Context) ([]int64, error) {
|
|
|
|
orgs := make([]int64, 0)
|
2022-10-19 08:02:15 -05:00
|
|
|
err := st.SQLStore.WithDbSession(ctx, func(sess *db.Session) error {
|
2021-08-24 05:28:09 -05:00
|
|
|
q := "SELECT id FROM org"
|
|
|
|
if err := sess.SQL(q).Find(&orgs); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return orgs, nil
|
|
|
|
}
|