package cz.utb.tadis.news.repository;

import cz.utb.tadis.news.model.New;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface NewsRepository extends JpaRepository<New, Long> {

    @Query(value="select * from news where id < ?1 order by id desc limit ?2 ", nativeQuery = true)
    List<New> findNextBatch(Long id, Long batchSize);

    @Query(value="select * from news order by id desc limit ?1 ", nativeQuery = true)
    List<New> findFirstBatch(Long batchSize);

    List<New> findAllByOrderByIdDesc();
}

