package subscriberepository

import (
	"fmt"
	"legalgo-BE-go/database"

	"gorm.io/gorm/clause"
)

func (a *SubsAccs) UpdateSubscribeStatus(spec database.Subscribe) error {
	if err := a.DB.Clauses(clause.OnConflict{
		Columns:   []clause.Column{{Name: "id"}},
		DoUpdates: clause.AssignmentColumns([]string{"status"}),
	}).Create(&spec).Error; err != nil {
		return fmt.Errorf("failed to update status: %v", err)
	}

	return nil
}
