• <small id='Yi2TL'></small><noframes id='Yi2TL'>

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

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

      1. Sequelize 带有日期的 Where 语句

        时间:2023-09-03
      2. <tfoot id='tZvIZ'></tfoot>

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

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

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

                  问题描述

                  我使用 Sequelize 作为我的后端 ORM.现在我想在日期上做一些 WHERE 操作.

                  I am using Sequelize as my backend ORM. Now I wish to do some WHERE operations on a Date.

                  更具体地说,我想获取日期介于现在和 7 天前之间的所有数据.

                  More specifically, I want to get all data where a date is between now and 7 days ago.

                  问题是文档没有指定可以对 Datatypes.DATE

                  The problem is that the documentation does not specify which operations you can do on Datatypes.DATE

                  谁能指出我正确的方向?

                  Can anyone point me in the right direction?

                  推荐答案

                  就像 Molda 说的,你可以使用 $gt, $lt, $gte$lte 带日期:

                  Just like Molda says, you can use $gt, $lt, $gte or $lte with a date:

                  model.findAll({
                    where: {
                      start_datetime: {
                        $gte: moment().subtract(7, 'days').toDate()
                      }
                    }
                  })
                  

                  如果您使用的是 Sequelize v5,则必须包含 Op 因为密钥已移至 Symbol

                  If you're using v5 of Sequelize, you've to include Op because the key was moved into Symbol

                  const { Op } = require('sequelize')
                  
                  model.findAll({
                    where: {
                      start_datetime: {
                        [Op.gte]: moment().subtract(7, 'days').toDate()
                      }
                    }
                  })
                  

                  在此处查看更多续集文档

                  这篇关于Sequelize 带有日期的 Where 语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Sequelize ORM中连接表的条件 下一篇:TypeError:无法读取未定义的属性“findAll"(expressjs)

                  相关文章

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

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

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

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