Package com.patreonshout.jpa
Interface PostsRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<PostBean,java.lang.Integer>,org.springframework.data.jpa.repository.JpaRepository<PostBean,java.lang.Integer>,org.springframework.data.repository.PagingAndSortingRepository<PostBean,java.lang.Integer>,org.springframework.data.repository.query.QueryByExampleExecutor<PostBean>,org.springframework.data.repository.Repository<PostBean,java.lang.Integer>
public interface PostsRepository extends org.springframework.data.jpa.repository.JpaRepository<PostBean,java.lang.Integer>
Spring Data Repository for easy use of CRUD operations on the
PostBean object-
Method Summary
Modifier and Type Method Description java.util.List<PostBean>findAllByCampaignId(int campaignId)Returns a list of posts by the creatorPostBeanfindPostBeanByUrl(java.lang.String url)returns a post by the post's linkjava.util.List<java.lang.Object[]>findPostsInListByListId(int list_id, java.lang.String url)find the posts in a list by list_idjava.util.List<PostBean>getExistingPosts(java.util.List<PostBean> pbList)getExistingPosts() checks what posts in thePostBeanobject list are already in the databaseorg.springframework.data.domain.Page<PostBean>getMultipleCreatorPosts(java.util.List<java.lang.String> campaignList, org.springframework.data.domain.Pageable pageable)Returns the posts from multiple creators in paginated json bodyMethods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, saveMethods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, findAll, findAll, findAllById, flush, getById, getOne, getReferenceById, saveAll, saveAllAndFlush, saveAndFlushMethods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findBy, findOne
-
Method Details
-
getMultipleCreatorPosts
@Query(value="SELECT * FROM posts WHERE campaign_id in ?1", countQuery="SELECT count(*) FROM posts WHERE campaign_id in ?1", nativeQuery=true) org.springframework.data.domain.Page<PostBean> getMultipleCreatorPosts(java.util.List<java.lang.String> campaignList, org.springframework.data.domain.Pageable pageable)Returns the posts from multiple creators in paginated json body- Parameters:
campaignList- is the list of creators we want to get posts frompageable- is thePageableobject we use to paginate our data- Returns:
- is the
Pageobject with our json body data holding posts from specified creators
-
findAllByCampaignId
Returns a list of posts by the creator- Parameters:
campaignId- is the creator's unique name- Returns:
- a list of
PostBeanobjects
-
findPostBeanByUrl
returns a post by the post's link- Parameters:
url- is the url of the post we want to find- Returns:
- a
PostBeanobject
-
getExistingPosts
getExistingPosts() checks what posts in thePostBeanobject list are already in the database -
findPostsInListByListId
@Query(value="SELECT * FROM list_posts RIGHT JOIN posts ON list_posts.post_id = posts.post_id where list_id = ?1", nativeQuery=true) java.util.List<java.lang.Object[]> findPostsInListByListId(int list_id, java.lang.String url)find the posts in a list by list_id- Parameters:
list_id- is the id of a list- Returns:
- a list of
PostBean
-