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