mirror of
https://git.rwth-aachen.de/acs/public/villas/web-backend-go/
synced 2025-03-30 00:00:12 +01:00
Fix of User.ID serialization:
As @skolen mentioned out, the `ID` field of the embedded struct `Model` in the model `User` must be serialized so it can be included in the responses. In the previous commit we completely ignored the field with the tag `json:"-"` so we can compare the serialized request (where ID was 0) with the response of the API. To limit the omission of the `User.ID` field only for the case that its value is 0 we modify the tag to `json:",omitempty"`.
This commit is contained in:
parent
76658c3ed4
commit
0fb9bc9157
1 changed files with 1 additions and 1 deletions
|
@ -10,7 +10,7 @@ import (
|
|||
// The type Model is exactly the same with gorm.Model (see jinzhu/gorm)
|
||||
// except the json tags that are needed for serializing the models
|
||||
type Model struct {
|
||||
ID uint `json:"-" gorm:"unique;primary_key:true"`
|
||||
ID uint `json:",omitempty" gorm:"unique;primary_key:true"`
|
||||
CreatedAt time.Time `json:"-"`
|
||||
UpdatedAt time.Time `json:"-"`
|
||||
DeletedAt *time.Time `json:"-" sql:"index"`
|
||||
|
|
Loading…
Add table
Reference in a new issue