pg
pg copied to clipboard
Enhancement: provide API to get column name from struct field name
Detailed Description
I would like to be able to a column name for a field in a struct. For example if I have a struct with a 'FirstName' field, it would return 'first_name'. Ideally this would also support custom column mappings.
I found some code in orm/table.go which uses an internal underscore method to create the column name. For now I can copy some of the internal logic, but this is not ideal.
Possible Implementation
A new method in pg package can return field name to column name mappings.
db.GetColumnName('FirstName') // returns "first_name"