I'm learning gorm through the official doc: https://gorm.io/docs/create.html
When coding the demo of Create from map, I can't understand the meaning of Note
When creating from map, ... primary key values won’t be back filled
But I still can find three records in my mysql which primary key values are back filled.
This is my code segment:
type User struct {
gorm.Model
Name string
Email *string
Age uint8
Birthday time.Time
MemberNumber sql.NullString
ActivateAt sql.NullTime
}
...
func createFromMap() {
db.Model(&User{}).Create(map[string]interface{}{
"Name": "jinZhu11", "Age": 18,
})
db.Model(&User{}).Create([]map[string]interface{}{
{"Name": "jinZhu8", "Age": 18},
{"Name": "jinZhu12", "Age": 20},
})
}
