This will change slightly depending on your mongoose version, but the method signature for findOne looks something like this:
function findOne (conditions, fields, options, callback)
What you mean as options (sorting), mongoose treats as fields (which fields to load).
You can try explicitly passing null for the fields:
models.user.findOne({}, null, {sort: {date_register: -1 }}, callback);
But if you can, you should probably use a query API that is more understandable, for example:
models.user.findOne({}).sort({date_register: -1}).exec(callback);
numbers1311407
source share