func DeleteItems(db *gorm.DB, data custom_structs.ItemsForDeleting) error { item := models.DBTypesMap()[data.Category] err := db.Where("id in (?)", data.Ids).Delete(item).Error if err != nil { return err } return nil }
func UpdateItem(db *gorm.DB, data custom_structs.ItemsData) error { var err error item := models.DBTypesMap()[data.Category] err = item.Decode(data.Data) if err == nil { itemValue := item.Value() err = db.Model(itemValue).Updates(itemValue).Error if err != nil { return err } } if err != nil { return err } return nil }
func AddItem(db *gorm.DB, category string) (error, interface{}) { item := models.DBTypesMap()[category] db.NewRecord(item) db.Create(item) return nil, item }