diff --git a/models/profile.js b/models/profile.js index e538920..c25dc7c 100644 --- a/models/profile.js +++ b/models/profile.js @@ -173,8 +173,9 @@ module.exports = { .select('messages') .populate({ path: 'messages', - match: { $and: [{ isUser: true }, { image: { $exists: true }, text: { $exists: false } }] }, - select: 'image -_id' + match: { $and: [{ isUser: true }, { image: { $exists: true } }, { text: { $exists: false } }] }, + select: 'image -_id', + sort: { order: 1 } }) .exec((err, result) => { if (err) {