diff --git a/models/profile.js b/models/profile.js index 56af12e..47211da 100644 --- a/models/profile.js +++ b/models/profile.js @@ -170,10 +170,11 @@ module.exports = { const promise = new Promise((resolve, reject) => { ProfileModel .aggregate([ - { $match: { _id: Mongoose.Types.ObjectId(profileId) } }, + { $match: { _id: Mongoose.Types.ObjectId(profileId), 'messages.image': { $exists: true } } }, { $unwind: '$messages' }, { $match: { 'messages.isUser': false, 'messages.image': { $exists: true } } } ]) + .select('messages -_id') .exec((err, result) => { if (err) { reject(err);