Limit MongoDB aggregation $lookup to only 1 match
问题 There are two collections, users and reports . My goal is to make an aggregation that gets all users and for each user includes the amount of user's last report . Here is my current aggregation: db.users.aggregate([{ $lookup: { from: 'reports', localField: '_id', foreignField: 'userId', as: 'report', }, }, { $project: { 'lastReportAmount': { $let: { vars: { lastReport: {'$arrayElemAt': ['$report', 0]}, }, in: '$$lastReport.amount', }, }, 'id': '$_id', 'name': 1, 'firstLogin': 1, 'email': 1, }