Create model_snake.go
It would be nice to be able force all models to use snake case on son response. In my projects all api endpoints returns always snake case. Gorm models are the only that are "hard" to do so.
This commit is contained in:
parent
8b07437717
commit
1a99c7bd1e
15
model_snake.go
Normal file
15
model_snake.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package gorm
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
// Model base model definition, including fields `ID`, `CreatedAt`, `UpdatedAt`, `DeletedAt`, which could be embedded in your models
|
||||||
|
// type User struct {
|
||||||
|
// gorm.ModelSC
|
||||||
|
// }
|
||||||
|
|
||||||
|
type ModelSC struct {
|
||||||
|
ID uint `gorm:"primary_key" json:"id"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
|
DeletedAt *time.Time `sql:"index" json:"deleted_at"`
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user