Skip to content

Commit

Permalink
uuid handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ecrupper committed Dec 6, 2023
1 parent f1853a2 commit 2264199
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions database/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,22 @@ func (d *Dashboard) Validate() error {
// DashboardFromLibrary converts the library Dashboard type
// to a database Dashboard type.
func DashboardFromLibrary(d *library.Dashboard) *Dashboard {
var (
id uuid.UUID
err error
)

if d.GetID() == "" {
id = uuid.New()
} else {
id, err = uuid.Parse(d.GetID())
if err != nil {
return nil
}
}

user := &Dashboard{
ID: id,
Name: sql.NullString{String: d.GetName(), Valid: true},
CreatedAt: sql.NullInt64{Int64: d.GetCreatedAt(), Valid: true},
CreatedBy: sql.NullString{String: d.GetCreatedBy(), Valid: true},
Expand Down

0 comments on commit 2264199

Please sign in to comment.