go-jet / jet

Type safe SQL builder with code generation and automatic query result data mapping
Apache License 2.0
2.52k stars 118 forks source link

Allow for `camelCase` type marshalling #246

Closed tommysalt closed 1 year ago

tommysalt commented 1 year ago

Go-Jet by defaults doesn't provide json annotations for marshaling.

type Message struct {
    ID      *int32 `sql:"primary_key"`
    Content *string
}

Is it possible to auto generate json marshaling annotations by looking at the table names in the schema for example? Is it possible to toggle between camelCase and TitleCase? Right now it uses TitleCase but camelCase is recommended for JSON (https://jsonapi.org/recommendations/)

Also, the table scheme calls the field id yet somehow Jet turns it into ID instead of Id.

go-jet commented 1 year ago

Hi @tommysalt , Yeah, it is possible, but you would need to customize generator first. Take a look at this example.

tommysalt commented 1 year ago

Ok, closing.