gorm: db.Create() do not touch updated_at field
Why updated_at field was updated in db.Create()?
Must be used only created_at field! We just created new item!! not updated!!
updated_at must be any default 0000-01-01 or nil (Updated_at *time.Time)
So when the item is Created() updated_at field is nil or default, then we can use updated_at field to view not moderated rows (new data) something like SELECT * FROM table WHERE updated_at IS NULL (or WHERE updated_at is 0000-01-01 (default)), but now i need to create a new field moderated and use it. Plix improve it!!!
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 15 (5 by maintainers)
You can customize
"gorm:update_time_stamp"Callback. https://github.com/jinzhu/gorm/blob/836fb2c19d84dac7b0272958dfb9af7cf0d0ade4/callback_create.go#L31-L48@franklingu I think you can use
sql:"DEFAULT"tag.