package de.oaa.xxx.feed.repository;

import de.oaa.xxx.feed.entity.FeedPostVoteEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.transaction.annotation.Transactional;

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

public interface FeedPostVoteRepository extends JpaRepository<FeedPostVoteEntity, UUID> {

    List<FeedPostVoteEntity> findByPostIdAndUserId(UUID postId, UUID userId);

    Optional<FeedPostVoteEntity> findByOptionIdAndUserId(UUID optionId, UUID userId);

    long countByOptionId(UUID optionId);

    @Transactional
    void deleteByPostId(UUID postId);
}
