When creating a new model, Gorma will automatically create an ID field on your model struct and set a gorm:"primary_key" struct tag. This is great.
What is confusing however is that the generated methods for retrieving a single item from the database won't take an ID parameter without an additional Field declaration in your model for a primary key:
Without the above, the Gorm Where method in both the generated OneFoo model helper and the Get model method only have an empty string as an argument, rendering them effectively useless.
When creating a new model, Gorma will automatically create an
ID
field on your model struct and set agorm:"primary_key"
struct tag. This is great.What is confusing however is that the generated methods for retrieving a single item from the database won't take an ID parameter without an additional
Field
declaration in your model for a primary key:Without the above, the Gorm
Where
method in both the generatedOneFoo
model helper and theGet
model method only have an empty string as an argument, rendering them effectively useless.