From a981c7e91938151cc063d29f799574ffcfc8d106 Mon Sep 17 00:00:00 2001 From: Mike Fitzpatrick Date: Sun, 4 Mar 2018 22:38:29 -0500 Subject: [PATCH] no message --- models/profile.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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);