These are chat archives for jinzhu/gorm

Jun 2016
Sarath Sadasivan Pillai
Jun 28 2016 06:33
Call backs can solve this pretty well. I changed the type of my datetime to a custome type and called it MysqlTime as the mysql needed formating for datetime different from the default time.Time formating .Here is how i did the callback work
//registering call back to be used to set created at for create requests
    gorm.DefaultCallback.Update().Register("gorm:update_time_stamp", func(scope *gorm.Scope) {
        if !scope.HasError() {
            now := func() MySQLDateTime {
                return *(NewMySQLDateTime(time.Now()))
            scope.SetColumn("UpdatedAt", now())
This is called in the init of dbhelper lib
Andrey Nering
Jun 28 2016 10:11
Thank you @sarathsp06 this will help. But I think the MySQL driver should properly handle thetime.Time type.