How to use sql NOW() as default value for the column when db.Create() using struct
Use DEFAULT CURRENT_TIMESTAMP for sql tag?
yea, bt the problem is that gorm dont know this and keep filling in "" to my DateTime field @jinzhu
This works for me:
TimeCreated time.Time gorm:"default:CURRENT_TIMESTAMP"
how about ON UPDATE CURRENT_TIMESTAMP?
@franklingu you can use BeforeSave hook for that https://gorm.io/docs/hooks.html
Most helpful comment
This works for me:
TimeCreated time.Time
gorm:"default:CURRENT_TIMESTAMP"