mirror of
https://github.com/nodemailer/wildduck.git
synced 2025-11-11 17:00:37 +08:00
use countDocuments
This commit is contained in:
parent
4e54ab5a6b
commit
268fbddc95
1 changed files with 18 additions and 14 deletions
|
|
@ -30,24 +30,26 @@ module.exports = server => (path, session, callback) => {
|
||||||
return callback(null, 'NONEXISTENT');
|
return callback(null, 'NONEXISTENT');
|
||||||
}
|
}
|
||||||
|
|
||||||
db.database
|
db.database.collection('messages').countDocuments(
|
||||||
.collection('messages')
|
{
|
||||||
.find({
|
|
||||||
mailbox: mailboxData._id
|
mailbox: mailboxData._id
|
||||||
})
|
},
|
||||||
.maxTimeMS(consts.DB_MAX_TIME_MESSAGES)
|
{
|
||||||
.count((err, total) => {
|
maxTimeMS: consts.DB_MAX_TIME_MESSAGES
|
||||||
|
},
|
||||||
|
(err, total) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
db.database
|
db.database.collection('messages').countDocuments(
|
||||||
.collection('messages')
|
{
|
||||||
.find({
|
|
||||||
mailbox: mailboxData._id,
|
mailbox: mailboxData._id,
|
||||||
unseen: true
|
unseen: true
|
||||||
})
|
},
|
||||||
.maxTimeMS(consts.DB_MAX_TIME_MESSAGES)
|
{
|
||||||
.count((err, unseen) => {
|
maxTimeMS: consts.DB_MAX_TIME_MESSAGES
|
||||||
|
},
|
||||||
|
(err, unseen) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
@ -58,8 +60,10 @@ module.exports = server => (path, session, callback) => {
|
||||||
uidValidity: mailboxData.uidValidity,
|
uidValidity: mailboxData.uidValidity,
|
||||||
unseen
|
unseen
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
});
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue