koprogo_api/application/ports/
poll_vote_repository.rs

1use crate::domain::entities::PollVote;
2use async_trait::async_trait;
3use uuid::Uuid;
4
5#[async_trait]
6pub trait PollVoteRepository: Send + Sync {
7    /// Create a new poll vote
8    async fn create(&self, vote: &PollVote) -> Result<PollVote, String>;
9
10    /// Find vote by ID
11    async fn find_by_id(&self, id: Uuid) -> Result<Option<PollVote>, String>;
12
13    /// Find all votes for a poll
14    async fn find_by_poll(&self, poll_id: Uuid) -> Result<Vec<PollVote>, String>;
15
16    /// Find vote by poll and owner (for duplicate checking)
17    async fn find_by_poll_and_owner(
18        &self,
19        poll_id: Uuid,
20        owner_id: Uuid,
21    ) -> Result<Option<PollVote>, String>;
22
23    /// Find all votes by an owner
24    async fn find_by_owner(&self, owner_id: Uuid) -> Result<Vec<PollVote>, String>;
25
26    /// Delete a vote
27    async fn delete(&self, id: Uuid) -> Result<bool, String>;
28}