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 (mongoose@3.0.1).
This worked for me:
Table1.findOne() .where({field1: 1}) .sort('-LAST_MOD') .exec(function(err, doc) { var max = doc.LAST_MOD; // ... } );
1.4m articles
1.4m replys
5 comments
57.0k users