const data = await this.notifModel.aggregate([ { $match: { author: id } }, { $lookup: { from: 'users', localField: 'notifications.author', foreignField: 'id', as: 'users', pipeline: [{ $project: { _id: 0, __v: 0, password: 0, email: 0 } }], }, }, { $project: { notifications: { $map: { input: '$notifications', as: 'c', in: { $mergeObjects: [ '$$c', { $arrayElemAt: [ { $filter: { input: '$users', cond: { $eq: ['$$c.notifications.author', '$$this._id'], }, }, }, 0, ], }, ], }, }, }, }, }, ]);