How to mimic a union type

Issue I know that using custom types is a common question, but bear with me… I would like to define a custom type ‘ConnectionInfo’ (see below): type DataSource struct { gorm.Model Name string Type DataSourceType `sql:"type:ENUM(‘POSTGRES’)" gorm:"column:data_source_type"` ConnectionInfo ConnectionInfo `gorm:"embedded"`

Continue reading

How can I add entire Array of structures into mysql database using GORM

Issue db.AutoMigrate(&student.Student{}) db.AutoMigrate(&address.Address{}) db.AutoMigrate(&subject.Subject{}) user := student.Student{ Adresses: []address.Address{ {City: "mum", State: "india", Country: "jjm", Pincode: "5859"}, {City: "muk", State: "inia", Country: "ojm", Pincode: "5779"}, {City: "pum", State: "rindia", Country: "8jm", Pincode: "6159"}, {City: "rum", State: "ljndia", Country: "hjm", Pincode:

Continue reading