rodrigogs / mongoose-timezone

Mongoose plugin to normalize stored dates timezone.
BSD 3-Clause "New" or "Revised" License
15 stars 6 forks source link

got timeout in all queries when collection is empty #3

Closed DeraldoSilva closed 5 years ago

DeraldoSilva commented 6 years ago

that's the versions I am using. "mongoose": "^4.13.8", "mongoose-timezone": "^1.1.0",

Agenda is my exported Model.

router.get('/', VerifyToken, (req, res, next) => {
    Agenda.find({})
        .then(agendas => {
            res.send(agendas);
        })
        .catch(err => {
            next(err);
        });
});
illuminzcode commented 5 years ago

Hi

Kindly update following in index.js

function subtractOffset(docs, next) { if (docs && !.isArray(docs)) docs = [docs.constructor.name === "model" ? docs : this]; ++++ if (docs.length == 0) next(); ++++ .each(docs, (result, index) => { fixOffset(result, false, () => { if (index + 1 === docs.length) next(); }); }); }

rodrigogs commented 5 years ago

Should be solved in https://github.com/rodrigogs/mongoose-timezone/releases/tag/v1.2.0