Skip to content

Instantly share code, notes, and snippets.

@BK1031
Last active July 11, 2024 11:25
Show Gist options
  • Save BK1031/b3a7deed67023cd96da6cbf57ed248c1 to your computer and use it in GitHub Desktop.
Save BK1031/b3a7deed67023cd96da6cbf57ed248c1 to your computer and use it in GitHub Desktop.
racecar_analytics update structs for db mapping
type ECU struct {
ID int `json:"id" gorm:"primaryKey"` // add this
MotorRPM int `json:"motor_rpm"`
Speed int `json:"speed"`
Throttle int `json:"throttle"`
BrakePressure int `json:"brake_pressure"`
CreatedAt time.Time `json:"created_at" gorm:"precision:6"` // add this
}
type Battery struct {
ID int `json:"id" gorm:"primaryKey"` // add this
ChargeLevel int `json:"charge_level"`
CellTemp1 int `json:"cell_temp_1"`
CellTemp2 int `json:"cell_temp_2"`
CellTemp3 int `json:"cell_temp_3"`
CellTemp4 int `json:"cell_temp_4"`
CellVoltage1 int `json:"cell_voltage_1"`
CellVoltage2 int `json:"cell_voltage_2"`
CellVoltage3 int `json:"cell_voltage_3"`
CellVoltage4 int `json:"cell_voltage_4"`
CreatedAt time.Time `json:"created_at" gorm:"precision:6"` // add this
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment