snapshot of https://github.com/traggo/server.git (master, 2026-09-16; blobs > 131072B omitted)
Some checks failed
build / build (push) Failing after 3s
Some checks failed
build / build (push) Failing after 3s
This commit is contained in:
27
dashboard/create.go
Normal file
27
dashboard/create.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package dashboard
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/traggo/server/dashboard/convert"
|
||||
|
||||
"github.com/traggo/server/auth"
|
||||
"github.com/traggo/server/generated/gqlmodel"
|
||||
"github.com/traggo/server/model"
|
||||
)
|
||||
|
||||
// CreateDashboard creates a dashboard.
|
||||
func (r *ResolverForDashboard) CreateDashboard(ctx context.Context, name string) (*gqlmodel.Dashboard, error) {
|
||||
userID := auth.GetUser(ctx).ID
|
||||
dashboard := model.Dashboard{
|
||||
UserID: userID,
|
||||
Name: name,
|
||||
}
|
||||
|
||||
create := r.DB.Create(&dashboard)
|
||||
if create.Error != nil {
|
||||
return &gqlmodel.Dashboard{}, create.Error
|
||||
}
|
||||
|
||||
return convert.ToExternalDashboard(dashboard)
|
||||
}
|
||||
Reference in New Issue
Block a user