Skip to content

Instantly share code, notes, and snippets.

@ntub46010
Created April 11, 2020 16:33
Show Gist options
  • Save ntub46010/d761bf1a9ba2b01444270cc9621bed44 to your computer and use it in GitHub Desktop.
Save ntub46010/d761bf1a9ba2b01444270cc9621bed44 to your computer and use it in GitHub Desktop.
// 回傳id欄位值有包含在參數之中的文件數量
@Query(value = "{'_id': {'$in': ?0}}", count = true)
int countByIdIn(List<String> ids);
// 回傳是否有文件的id欄位值包含在參數之中
@Query(value = "{'_id': {'$in': ?0}}", exists = true)
boolean existsByIdIn(List<String> ids);
// 刪除id欄位值包含在參數之中的文件
@Query(delete = true)
void deleteByIdIn(List<String> ids);
// 找出id欄位值有包含在參數之中的文件,並先後做name欄位遞增與price欄位遞減的排序
@Query(sort = "{'name': 1, 'price': -1}")
List<Product> findByIdInOrderByNameAscPriceDesc(List<String> ids);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment