package org.codiki.core.repositories;

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

import org.codiki.core.entities.persistence.Image;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

@Repository
public interface ImageRepository extends CrudRepository<Image, Long> {
	@Query(value = "SELECT * FROM image WHERE user_id = :userId", nativeQuery = true)
	List<Image> getByUserId(@Param("userId") final Long pUserId);
	
	@Query(value = "SELECT * FROM image WHERE link = :link", nativeQuery = true)
	Optional<Image> findByLink(@Param("link") final String pLink);
}
