我对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, }, }, ]);
添加回答
举报
0/150
提交
取消