no message
This commit is contained in:
@@ -169,26 +169,20 @@ module.exports = {
|
||||
allMessageImages: (e, profileId) => {
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
ProfileModel
|
||||
.findById(profileId, (err, profile) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
.aggregate(
|
||||
{ $match: { _id: profileId } },
|
||||
{ $unwind: '$messages' },
|
||||
{ $match: { 'messages.image': { $exists: true } } }
|
||||
)
|
||||
.exec((err, result) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
|
||||
if (profile) {
|
||||
profile.messages
|
||||
.find({ 'image': { $exists: true } })
|
||||
.select('image -_id')
|
||||
.exec((err, result) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
|
||||
if (result) {
|
||||
resolve(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
if (result) {
|
||||
resolve(result);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
promise.then((result) => {
|
||||
|
||||
Reference in New Issue
Block a user