gorm更新时 这个id 111 哪里来的呢

richLpf · · 509 次点击
111 從 &user 來的,只是一個假定值 https://gorm.io/docs/create.html type Animal struct { ID int64 Name string `gorm:"default:'galeone'"` Age int64 } var animal = Animal{Age: 99, Name: ""} db.Create(&animal) // INSERT INTO animals("age") values('99'); // SELECT name from animals WHERE ID=111; // the returning primary key is 111
#1