跃然一笑
mongodb中有聚合函数,可以使用聚合函数查询最值。案例代码://计算时间编号exports.maxSJBH = function ( callback) {var proxy = new EventProxy();PerMYDFXMongooseModel.aggregate([{$group: {_id: null,maxsjbh: {$max: "$sjbh"}}},{$project: {_id: 0,maxsjbh: "$maxsjbh"}}], proxy.done('models'));proxy.all('models', function (models) {callback(null, models);});}