Skip to content

Commit

Permalink
Merge pull request #64 from hmcalister/Add-Event-ID-to-frontend-binding
Browse files Browse the repository at this point in the history
Add Event ID to frontend binding using JSON tag
  • Loading branch information
hmcalister authored Sep 5, 2023
2 parents a8f1ec1 + e810b21 commit 2c97edd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 8 additions & 5 deletions backend/models/Event.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ import (
)

type Event struct {
gorm.Model
Name string `json:"Name"`
StartTime time.Time `json:"StartTime" ts_type:"Date" ts_transform:"new Date(__VALUE__)"`
TimeoutDuration time.Duration `json:"TimeoutDuration" ts_type:"number"`
IsRecurring bool `json:"IsRecurring"`
ID uint `gorm:"primaryKey" json:"ID" ts_type:"number"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
Name string `json:"Name"`
StartTime time.Time `json:"StartTime" ts_type:"Date" ts_transform:"new Date(__VALUE__)"`
TimeoutDuration time.Duration `json:"TimeoutDuration" ts_type:"number"`
IsRecurring bool `json:"IsRecurring"`
}

// Create a new Event
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lib/wailsjs/go/models.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export namespace models {

export class Event {
ID: number;
Name: string;
StartTime: Date;
TimeoutDuration: number;
Expand All @@ -12,6 +13,7 @@ export namespace models {

constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.ID = source["ID"];
this.Name = source["Name"];
this.StartTime = new Date(source["StartTime"]);
this.TimeoutDuration = source["TimeoutDuration"];
Expand Down

0 comments on commit 2c97edd

Please sign in to comment.