package studycave.studycaverestservice.model.studyGroupMember;

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

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface StudyGroupMemberRepository extends JpaRepository<StudyGroupMember, Long> {

    @Query("select t from StudyGroupMember t where t.user.id = :i")
    List<StudyGroupMember> findByMember(@Param("i") Long i);


    @Query("select t from StudyGroupMember t where (t.group.id = :g and t.user.id = :u)")
    StudyGroupMember findUserInGroup(@Param("g") Integer g, @Param("u") Long u);

    Optional<StudyGroupMember> findByUserUsosUserUsosIdAndGroupUsosGroupId(String id, String groupId);
}
