我想知道是否有任何机制可以在Spring Data MongoDB存储库中使用count
和@Query
注释?
基本上,这在Java中相当于:
db.test.find({"type":"foo"}).count
我想知道是否有任何机制可以在Spring Data MongoDB存储库中使用count
和@Query
注释?
基本上,这在Java中相当于:
db.test.find({"type":"foo"}).count
对我来说,这个解决方案很有魅力(使用spring data mongodb 1.3.1.RELEASE),
@Query(value = "{'productDetails.productType': {$regex: ?0, $options: 'i'}, 'sourceDescriptor': ?1}", count = true)
public Long countFetchedDocumentsForCategory(String cat, String sourceDescriptor);