refactor: updates delete method to return affected rows count

This commit is contained in:
2025-11-01 20:29:39 -03:00
parent e06c30635e
commit af511203a4
2 changed files with 7 additions and 4 deletions

View File

@@ -69,8 +69,11 @@ func (r *baseRepository[T]) GetAll() ([]T, error) {
return entities, nil
}
func (r *baseRepository[T]) Delete(id int) error {
func (r *baseRepository[T]) Delete(id int) (int64, error) {
query := r.BuildQuery("DELETE %s WHERE id = ? LIMIT 1")
_, err := r.db.Exec(query, id)
return err
res, err := r.db.Exec(query, id)
if err != nil {
return 0, err
}
return res.RowsAffected()
}