how to get maximum value in mongoose query . in SQL it is easy
SELECT MAX(LAST_MOD) FROM table1 Where field1=1
i want Equivalent of above SQL code in mongoose(node.js)
I couldn't get the other answers to work. Perhaps I'm using a newer version of Mongoose ([email protected]).
This worked for me:
Table1.findOne() .where({field1: 1}) .sort('-LAST_MOD') .exec(function(err, doc) { var max = doc.LAST_MOD; // ... } );
2.1m questions
2.1m answers
60 comments
57.0k users