package app.mealsmadeeasy.api.auth;

import jakarta.transaction.Transactional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.Optional;
import java.util.UUID;

public interface RefreshTokenRepository extends JpaRepository<RefreshToken, UUID> {

    Optional<RefreshToken> findByToken(UUID token);

    @Modifying
    @Transactional
    @Query("DELETE FROM RefreshToken t WHERE t.deleted = true")
    void deleteAllWhereSoftDeleted();

}
