Friday, 12 May 2017

Mongoose sorting numbers wrong way

I have a simple Schema in mongoose:

var ShotSchema = new mongoose.Schema({
  code: Number,
  active: Boolean
});

After running this static function to sort query by code number:

findShotMax: function(seq, cb) {
  this.find({sequence: seq})
  .sort('code')
  // .limit(1)
  .exec(cb);
}

I get shots sorted in



via pind0l

No comments:

Post a Comment