V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐工具
RoboMongo
推荐书目
50 Tips and Tricks for MongoDB Developers
Related Blogs
Snail in a Turtleneck
yinft
V2EX  ›  MongoDB

求助帖

  •  
  •   yinft · 2021-10-29 10:13:44 +08:00 · 1684 次点击
    这是一个创建于 881 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

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

    5 条回复    2021-10-29 14:04:17 +08:00
    yinft
        1
    yinft  
    OP
       2021-10-29 10:20:58 +08:00
    ![01f9f6a04620590997de43ab3178d12.png]( https://i.loli.net/2021/10/29/XlrG1t8DZN32zsQ.png)
    我用了 when 的话只能满足两个条件,然后尝试了 ConditionalOperators,但是发现好像条件只能大于没有小于?
    yinft
        2
    yinft  
    OP
       2021-10-29 10:22:20 +08:00
    只有 greaterthan 方法没有 lessthen 方法
    sssszaw
        4
    sssszaw  
       2021-10-29 13:38:22 +08:00
    @sssszaw 去掉汉字,额
    yinft
        5
    yinft  
    OP
       2021-10-29 14:04:17 +08:00
    @sssszaw 看了相应的 spring data mongo 的文档没找到
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1006 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 22:03 · PVG 06:03 · LAX 15:03 · JFK 18:03
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.