关于mongodb 分组的问题 Invalid reference 'userId'!

wuhuan0418 2018-07-02 05:05:29
Criteria criteria = Criteria.where("businessCode").is(businessCode).and("optime").regex(month);
Aggregation aggregation = Aggregation.newAggregation(Aggregation.project("deviceType", "num"),
Aggregation.match(criteria), Aggregation.group("userId").count().
as("num"));

根据userid进行分组,然后报错
...全文
2789 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
wuhuan0418 2018-07-03
  • 打赏
  • 举报
回复 3
已解决,Aggregation.project("deviceType", "num")需要增加userId字段,被自己蠢哭

1,746

社区成员

发帖
与我相关
我的任务
社区描述
MongoDB相关内容讨论区
社区管理员
  • MongoDB社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧