From c11f9cb3c7a30cc11e7d7c0c0d788bc041f084a6 Mon Sep 17 00:00:00 2001 From: Mike Fitzpatrick Date: Sun, 4 Mar 2018 21:59:04 -0500 Subject: [PATCH] no message --- models/profile.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/models/profile.js b/models/profile.js index 73b59e2..ce92223 100644 --- a/models/profile.js +++ b/models/profile.js @@ -169,8 +169,13 @@ module.exports = { allMessageImages: (e, profileId) => { const promise = new Promise((resolve, reject) => { ProfileModel - .find({ _id: profileId, messages: { $elemMatch: { image: { $ne: null } } } }) - .select('messages') + .find({ _id: profileId }) + .select('messages') + .populate({ + match: { image: { $ne: null } }, + path: 'messages', + select: 'image' + }) .exec((err, result) => { if (err) { reject(err);