gen icon indicating copy to clipboard operation
gen copied to clipboard

How to customize the field names of the generated model?

Open szerr opened this issue 1 year ago • 1 comments

Recently I want to switch to gen to generate models. "id" and "*_id" in the table are all converted to "ID", and the existing field in the project is "Id". I want to reduce the impact on the project. Is it possible to use a callback function to return a custom name?

szerr avatar May 14 '24 10:05 szerr

You can try to modify the NamingStrategy. https://gorm.io/docs/gorm_config.html#NamingStrategy NameReplacer: strings.NewReplacer("ID", "Id")

qqxhb avatar Jun 17 '24 04:06 qqxhb