I am storing my struct values in google data store. Here is my struct:
type Appointment struct {
ID string
Appointment Date string
Start Time string
End Time string
Select Specialization string
Smoking Status string
}
I have stored some data using datastore, but later changed the data type from string to bool for the field "Smoking Status" then the data store is throwing an error:
{"error":{"message":"data store: cannot load field \\"Smoking Status\\" into a \\"simplysthealth.Encounter\\": type mismatch: string versus bool"}}
Is there any feasible solution for this?
package main
// I have corrected all of your method names
type Appointment struct {
ID string
AppointmentDate string
StartTime string
EndTime string
SelectSpecialization string
SmokingStatus string
}
type AllOldData struct {
Data []Appointment
}
type FixedAppointment struct {
ID string
AppointmentDate string
StartTime string
EndTime string
SelectSpecialization string
SmokingStatus bool
}
type FixedData struct {
Data []FixedAppointment
}
func TypeFixing() FixedData {
var OldData AllOldData
var NewData FixedData
OldData = GetYourAllOldData()
for i, v := range OldData.Data {
if v.SmokingStatus == "true" {
// other value exchanging
NewData.Data[i].SmokingStatus = true
} else {
// other value exchanging
NewData.Data[i].SmokingStatus = false
}
}
return NewData // Save the data in a new table or whatever you call it
}
func GetYourAllOldData() AllOldData {
// A function that returns all old data
return AllOldData{} // You must return return your all data
}
This is what you need to do it manually!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.