-
Relationship struct are not being marshaled to json because of the json:"-" tag. Is there a workaround for this? // Reading is an object representing the database table.
type Reading struct {
ID uuid.UUID `db:"id,pk" json:"id"`
SensorID uuid.UUID `db:"sensor_id" json:"sensor_id"`
ReadingTime time.Time `db:"reading_time" json:"reading_time"`
MeasurementStartTime time.Time `db:"measurement_start_time" json:"measurement_start_time"`
MeasurementEndTime time.Time `db:"measurement_end_time" json:"measurement_end_time"`
CreateTime time.Time `db:"create_time" json:"create_time"`
UpdateTime time.Time `db:"update_time" json:"update_time"`
R readingR `db:"-" json:"-"` // This tag
}
// readingR is where relationships are stored.
type readingR struct {
BaseReadings BaseReadingSlice `json:"base_readings"` // base_readings.base_readings_sensor_id_reading_id_fkey
File *File `json:"file"` // files.files_reading_id_fkey
Points PointSlice `json:"points"` // points.points_reading_id_fkey
Sensor *Sensor `json:"sensor"` // readings.readings_sensor_id_fkey
} Should I create a custom dto to return the response to the client? What are your suggestions? |
Beta Was this translation helpful? Give feedback.
Answered by
fseda
Dec 2, 2024
Replies: 1 comment
-
So apparently there's a way to configure the json tag for relationships. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
fseda
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So apparently there's a way to configure the json tag for relationships.