推荐工具
RoboMongo
推荐书目
50 Tips and Tricks for MongoDB Developers
Related Blogs
Snail in a Turtleneck
yinft
V2EX  ›  MongoDB

求助帖

  •  
  •   yinft · Oct 29, 2021 · 2430 views
    This topic created in 1675 days ago, the information mentioned may be changed or developed.

    mongodb 里面 对标 mysql 的 case when 是怎么查询的,找了半天没找到实用的。用 mongotemplate 怎么写,麻烦有没有大佬给个资料或者直接指点一下。 4346e3eb11bd4d389afeabbd916c121.png

    我想按照这个 startTime ,每天分组求和, 把 6 点到 9 点的 flowInNum 字段数据求和然后给个新字段 monring 默认是早上 把 11 点到 13 点的 flowInNum 字段数据求和然后给个新字段 afternoon 默认是中午 把 18 点到 20 点的 flowInNum 字段数据求和然后给个新字段 night 默认是晚上

    5 replies    2021-10-29 14:04:17 +08:00
    yinft
        1
    yinft  
    OP
       Oct 29, 2021
    ![01f9f6a04620590997de43ab3178d12.png]( https://i.loli.net/2021/10/29/XlrG1t8DZN32zsQ.png)
    我用了 when 的话只能满足两个条件,然后尝试了 ConditionalOperators,但是发现好像条件只能大于没有小于?
    yinft
        2
    yinft  
    OP
       Oct 29, 2021
    只有 greaterthan 方法没有 lessthen 方法
    sssszaw
        4
    sssszaw  
       Oct 29, 2021
    @sssszaw 去掉汉字,额
    yinft
        5
    yinft  
    OP
       Oct 29, 2021
    @sssszaw 看了相应的 spring data mongo 的文档没找到
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2893 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 08:41 · PVG 16:41 · LAX 01:41 · JFK 04:41
    ♥ Do have faith in what you're doing.