use object for sorting

This commit is contained in:
Andris Reinman 2020-01-29 17:58:59 +02:00
parent 1676c7336f
commit fafc124f83
No known key found for this signature in database
GPG key ID: 5388A30A31834D83
6 changed files with 7 additions and 6 deletions

View file

@ -55,7 +55,7 @@ module.exports = (server, messageHandler) => (mailbox, update, session, callback
mailbox: mailboxData._id,
uid: tools.checkRangeQuery(update.messages)
}) // no projection as we need to copy the entire message
.sort([['uid', 1]])
.sort({ uid: 1 })
.maxTimeMS(consts.DB_MAX_TIME_MESSAGES);
let copiedMessages = 0;

View file

@ -78,7 +78,7 @@ module.exports = (server, messageHandler) => (mailbox, update, session, callback
let cursor = db.database
.collection('messages')
.find(query)
.sort([['uid', 1]])
.sort({ uid: 1 })
.maxTimeMS(consts.DB_MAX_TIME_MESSAGES);
let processNext = () => {

View file

@ -130,11 +130,12 @@ module.exports = (server, messageHandler, userCache) => (mailbox, options, sessi
return callback(...args);
};
let sort = { uid: 1 };
let cursor = db.database
.collection('messages')
.find(query)
.project(projection)
.sort([['uid', 1]])
.sort(sort)
.setReadPreference('secondaryPreferred')
.maxTimeMS(consts.DB_MAX_TIME_MESSAGES);

View file

@ -38,7 +38,7 @@ module.exports = server => (path, session, callback) => {
.project({
uid: true
})
//.sort([['uid', 1]])
//.sort({ uid: 1 })
.maxTimeMS(consts.DB_MAX_TIME_MESSAGES)
.toArray((err, messages) => {
if (err) {

View file

@ -92,7 +92,7 @@ module.exports = server => (mailbox, update, session, callback) => {
modseq: true
})
.maxTimeMS(consts.DB_MAX_TIME_MESSAGES)
.sort([['uid', 1]]);
.sort({ uid: 1 });
let shouldExpunge = false;
let updateEntries = [];

View file

@ -126,7 +126,7 @@ const serverOptions = {
flags: true,
unseen: true
})
.sort([['uid', -1]])
.sort({ uid: -1 })
.limit(config.pop3.maxMessages || MAX_MESSAGES)
.toArray((err, messages) => {
if (err) {