<tfoot id='WnZwz'></tfoot>

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

    • <bdo id='WnZwz'></bdo><ul id='WnZwz'></ul>

  1. <legend id='WnZwz'><style id='WnZwz'><dir id='WnZwz'><q id='WnZwz'></q></dir></style></legend>

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

    1. Spring Data MongoDB 日期之间

      时间:2024-08-23
      1. <i id='o72SX'><tr id='o72SX'><dt id='o72SX'><q id='o72SX'><span id='o72SX'><b id='o72SX'><form id='o72SX'><ins id='o72SX'></ins><ul id='o72SX'></ul><sub id='o72SX'></sub></form><legend id='o72SX'></legend><bdo id='o72SX'><pre id='o72SX'><center id='o72SX'></center></pre></bdo></b><th id='o72SX'></th></span></q></dt></tr></i><div id='o72SX'><tfoot id='o72SX'></tfoot><dl id='o72SX'><fieldset id='o72SX'></fieldset></dl></div>

            • <bdo id='o72SX'></bdo><ul id='o72SX'></ul>

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

                <tbody id='o72SX'></tbody>
              <tfoot id='o72SX'></tfoot>
                <legend id='o72SX'><style id='o72SX'><dir id='o72SX'><q id='o72SX'></q></dir></style></legend>

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

                问题描述

                我用的是spring data mongodb.

                I use spring data mongodb.

                我想要两个日期之间的记录.以下 MongoDB 查询有效:

                I want the records between two dates. The following MongoDB Query works:

                db.posts.find({startDate: {$gte: start, $lt: end}});
                

                我尝试的 Spring 数据查询对象代码翻译不起作用:

                My attempted Spring data query object code translation does not work:

                Query query = new Query();
                query.addCriteria(Criteria.where("startDate").gte(startDate)
                                            .and("startDate").lt(endDate));
                

                构建我需要的 Mongo 查询的方法调用的正确顺序是什么?

                What is the correct order of method calls to build the Mongo query I need?

                推荐答案

                不要在您的标准中包含 'and("startDate")' 部分.

                Do not include the 'and("startDate")' part in your criteria.

                而不是:

                query.addCriteria(Criteria.where("startDate").gte(startDate).and("startDate").lt(endDate));
                

                你应该使用:

                query.addCriteria(Criteria.where("startDate").gte(startDate).lt(endDate));
                

                当您包含 'and("startDate")' 部分时,Mongo 将其视为同一属性上的两个不同条目.

                When you include the 'and("startDate")' part, Mongo see's it as two different entries on the same property.

                这篇关于Spring Data MongoDB 日期之间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:Spring mongo 查询设置自定义超时 下一篇:Spring Data Join 规范

                相关文章

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

                <legend id='34wkz'><style id='34wkz'><dir id='34wkz'><q id='34wkz'></q></dir></style></legend>

                1. <small id='34wkz'></small><noframes id='34wkz'>

                    <bdo id='34wkz'></bdo><ul id='34wkz'></ul>