<tfoot id='xwo49'></tfoot>
  • <small id='xwo49'></small><noframes id='xwo49'>

    1. <i id='xwo49'><tr id='xwo49'><dt id='xwo49'><q id='xwo49'><span id='xwo49'><b id='xwo49'><form id='xwo49'><ins id='xwo49'></ins><ul id='xwo49'></ul><sub id='xwo49'></sub></form><legend id='xwo49'></legend><bdo id='xwo49'><pre id='xwo49'><center id='xwo49'></center></pre></bdo></b><th id='xwo49'></th></span></q></dt></tr></i><div id='xwo49'><tfoot id='xwo49'></tfoot><dl id='xwo49'><fieldset id='xwo49'></fieldset></dl></div>

        <legend id='xwo49'><style id='xwo49'><dir id='xwo49'><q id='xwo49'></q></dir></style></legend>
          <bdo id='xwo49'></bdo><ul id='xwo49'></ul>

        在 Spring Data MongoDB 存储库中计数

        时间:2024-08-24

            <tbody id='kkTGS'></tbody>

          <small id='kkTGS'></small><noframes id='kkTGS'>

          <i id='kkTGS'><tr id='kkTGS'><dt id='kkTGS'><q id='kkTGS'><span id='kkTGS'><b id='kkTGS'><form id='kkTGS'><ins id='kkTGS'></ins><ul id='kkTGS'></ul><sub id='kkTGS'></sub></form><legend id='kkTGS'></legend><bdo id='kkTGS'><pre id='kkTGS'><center id='kkTGS'></center></pre></bdo></b><th id='kkTGS'></th></span></q></dt></tr></i><div id='kkTGS'><tfoot id='kkTGS'></tfoot><dl id='kkTGS'><fieldset id='kkTGS'></fieldset></dl></div>
          • <bdo id='kkTGS'></bdo><ul id='kkTGS'></ul>
              <legend id='kkTGS'><style id='kkTGS'><dir id='kkTGS'><q id='kkTGS'></q></dir></style></legend>
              • <tfoot id='kkTGS'></tfoot>

                • 本文介绍了在 Spring Data MongoDB 存储库中计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想知道是否有任何机制可以在 Spring Data MongoDB 存储库中使用 count@Query 注释?我很想收到我所拥有的文件数量,而不必获取所有文件.

                  I wonder if there's any mechanism to use count in Spring Data MongoDB repository with @Query annotation? I would love to receive the number of documents that I have without having to get all of them.

                  基本上相当于Java中的this:

                  Basically, the equivalent of this in Java:

                  db.test.find({"type":"foo"}).count 
                  

                  推荐答案

                  对我来说,这个解决方案就像一个魅力(使用 spring-data-mongodb 1.3.1.RELEASE ),我刚刚遇到了同样的问题并像这样解决了它(只是我工作代码中的一小段):

                  For me this solutions works like a charm( using spring-data-mongodb 1.3.1.RELEASE ), I just had the same problem atm and solved it like this(just a short snippet from my code at work):

                  @Query(value = "{'productDetails.productType': {$regex: ?0, $options: 'i'}, 'sourceDescriptor': ?1}", count = true)
                  public Long countFetchedDocumentsForCategory(String cat, String sourceDescriptor);
                  

                  这篇关于在 Spring Data MongoDB 存储库中计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何检索给定域类的弹簧数据存储库实例? 下一篇:为什么我看不到通过 Spring Data JPA 的更新查询发出的更改?

                  相关文章

                    1. <small id='O7k7p'></small><noframes id='O7k7p'>

                      <i id='O7k7p'><tr id='O7k7p'><dt id='O7k7p'><q id='O7k7p'><span id='O7k7p'><b id='O7k7p'><form id='O7k7p'><ins id='O7k7p'></ins><ul id='O7k7p'></ul><sub id='O7k7p'></sub></form><legend id='O7k7p'></legend><bdo id='O7k7p'><pre id='O7k7p'><center id='O7k7p'></center></pre></bdo></b><th id='O7k7p'></th></span></q></dt></tr></i><div id='O7k7p'><tfoot id='O7k7p'></tfoot><dl id='O7k7p'><fieldset id='O7k7p'></fieldset></dl></div>
                    2. <tfoot id='O7k7p'></tfoot>

                    3. <legend id='O7k7p'><style id='O7k7p'><dir id='O7k7p'><q id='O7k7p'></q></dir></style></legend>
                        <bdo id='O7k7p'></bdo><ul id='O7k7p'></ul>