func resetSeq(tasks *[]db.Task) error {
	tx := db.Conn.Begin()
	defer func() {
		if r := recover(); r != nil {
			tx.Rollback()
		}
	}()
	if err := tx.Error; err != nil {
		return err
	}

	if err := tx.Model(&db.Task{}).Where("1 = 1").Update("seq", nil).Error; err != nil {
		return err
	}

	for i := 0; i < len(*tasks); i++ {
		thisTask := &(*tasks)[i]
		thisTask.Seq = i + 1
		if err := tx.Save(&thisTask).Error; err != nil {
			return err
		}
	}
	return tx.Commit().Error
}
// resetSeq assigns new seq numbers, numbering only tasks provided in parameter.
resetSeq assigns new seq numbers, numbering only tasks provided in parameter.
// resetSeq assigns new seq numbers numbering only tasks provided in parameter .
func resetSeq(tasks *[]db.Task) error {
	tx := db.Conn.Begin()
	defer func() {
		if r := recover(); r != nil {
			tx.Rollback()
		}
	}()
	if err := tx.Error; err != nil {
		return err
	}
	if err := tx.Model(&db.Task{}).Where("1 = 1").Update("seq", nil).Error; err != nil {
		return err
	}
	for i := 0; i < len(*tasks); i++ {
		thisTask := &(*tasks)[i]
		thisTask.Seq = i + 1
		if err := tx.Save(&thisTask).Error; err != nil {
			return err
		}
	}
	return tx.Commit().Error
}
func resetSeq ( tasks * [ ] db . Task ) error { tx := db . Conn . Begin ( ) defer func ( ) { if r := recover ( ) ; r != nil { tx . Rollback ( ) } } ( ) if err := tx . Error ; err != nil { return err } if err := tx . Model ( & db . Task { } ) . Where ( " " ) . Update ( " " , nil ) . Error ; err != nil { return err } for i := 0 ; i < len ( * tasks ) ; i ++ { thisTask := & ( * tasks ) [ i ] thisTask . Seq = i + 1 if err := tx . Save ( & thisTask ) . Error ; err != nil { return err } } return tx . Commit ( ) . Error }
resetSeq assigns new seq numbers, numbering only tasks provided in parameter.
resetSeq assigns new seq numbers numbering only tasks provided in parameter .