ant0ine / go-json-rest-examples

Examples for go-json-rest
http://ant0ine.github.io/go-json-rest/
MIT License
195 stars 52 forks source link

GORM Demo Struct Definition #21

Closed andystroz closed 5 years ago

andystroz commented 7 years ago

For the GORM demo the struct definition should be

type Reminder struct {
    Id        int64     `json:"id"`
    Message   string    `sql:"size:1024" json:"message"`
    CreatedAt time.Time `json:"createdAt"`
    UpdatedAt time.Time `json:"updatedAt"`
    DeletedAt *time.Time `json:"-"`
}

If the DeletedAt param is not defined as *time.Time the the PutReminder function will save not NULL to the DeletedAt column in the database. Consequently calling i.DB.First(&reminder, id).Error returns a record not found error.