2022-05-03 15:26:32 +05:30
|
|
|
package sqlite
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
2025-03-20 21:01:41 +05:30
|
|
|
"github.com/SigNoz/signoz/pkg/query-service/model"
|
|
|
|
|
"github.com/SigNoz/signoz/pkg/types"
|
2022-05-03 15:26:32 +05:30
|
|
|
)
|
|
|
|
|
|
2025-03-06 15:39:45 +05:30
|
|
|
func (mds *ModelDaoSqlite) GetOrgs(ctx context.Context) ([]types.Organization, *model.ApiError) {
|
|
|
|
|
var orgs []types.Organization
|
|
|
|
|
err := mds.bundb.NewSelect().
|
|
|
|
|
Model(&orgs).
|
|
|
|
|
Scan(ctx)
|
2022-05-03 15:26:32 +05:30
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, &model.ApiError{Typ: model.ErrorInternal, Err: err}
|
|
|
|
|
}
|
|
|
|
|
return orgs, nil
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-14 23:12:55 +05:30
|
|
|
func (mds *ModelDaoSqlite) UpdateUserRole(ctx context.Context, userId string, role types.Role) *model.ApiError {
|
2022-05-03 15:26:32 +05:30
|
|
|
|
2025-03-06 15:39:45 +05:30
|
|
|
_, err := mds.bundb.NewUpdate().
|
|
|
|
|
Model(&types.User{}).
|
2025-04-26 15:50:02 +05:30
|
|
|
Set("role = ?", role).
|
2025-03-06 15:39:45 +05:30
|
|
|
Where("id = ?", userId).
|
|
|
|
|
Exec(ctx)
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
2022-05-03 15:26:32 +05:30
|
|
|
return &model.ApiError{Typ: model.ErrorInternal, Err: err}
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|