为了账号安全,请及时绑定邮箱和手机立即绑定

为什么我的汇总返回重复数据?

为什么我的汇总返回重复数据?

一只斗牛犬 2021-04-20 09:14:30
我对mongo聚合还很陌生,所以我的鼻子出现在mongo文档中试图解决它。越来越近了!我正在对数据集运行一些查询,以从保存数据文档中获取当前结果。但是我得到的响应是集合中第一个结果的重复。const result = await MemoryCard.aggregate([    {      $lookup: {        from: 'users',        localField: 'owner',        foreignField: '_id',        as: 'owner',      },    },    {'$unwind': '$owner'},    {$unwind: '$progress'},    {$match: {      'progress.createdAt': {        $gte: d,        $lte: new Date(),      },      'progress.file_one': {$eq: true},      'progress.file_two': {$eq: true},    }},    {$unwind: '$profiles'},    {      '$project': {        'owner.email': 1,        'owner.username': 1,        'progress': 1,        'profiles': 1,      },    },  ]);
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 157 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信