diff --git a/models/profile.js b/models/profile.js index 29a2d03..4720f20 100644 --- a/models/profile.js +++ b/models/profile.js @@ -173,7 +173,7 @@ module.exports = { { $match: { _id: Mongoose.Types.ObjectId(profileId), 'messages.image': { $exists: true } } }, { $unwind: '$messages' }, { $match: { 'messages.isUser': false, 'messages.image': { $exists: true } } }, - { $replaceRoot: { newRoot: '$messages.image' } } + { $replaceRoot: { newRoot: '$messages' } } ]) .project('messages.image -_id') .exec((err, result) => {