Go
Published
【Gorm】主キーがstringの時のFind
NG
id := "hogehoge"
db.Find(&user, id)
OK
id := "hogehoge"
db.Find(&user, "id = ?", id)
ドキュメント
https://gorm.io/ja_JP/docs/query.html#Retrieving-objects-with-primary-key
NG
id := "hogehoge"
db.Find(&user, id)
OK
id := "hogehoge"
db.Find(&user, "id = ?", id)
ドキュメント
https://gorm.io/ja_JP/docs/query.html#Retrieving-objects-with-primary-key