node package manager


Provides Mongoose v2 sub-classed Number with atomic increment/decrement support



Provides Mongoose v2 Number support for Mongoose v3.

Build Status


var mongoose = require('mongoose')
var partSchema = new Schema({ num: 'MongooseNumber' });
var Part = db.model('Part', partSchema);
var part = new Part({ num: 47 }); (err) {
  Part.findById(part, function (err, part) {
    part.num.increment(); // uses atomic $inc (err) {
      Part.findById(part, function (err, part) {
        console.log(part.num) // 48 

In Mongoose v2 every number was cast to this custom type. This type was removed due to the following caveats:

run this gist

Observe the result of typeof a.n1. Its "object" not "number"! Next observe the direct comparison of two mongoose numbers, a.n1 == a.n2 is false. This makes javascript programs very sad.

So the benefits of handy helper methods that are rarely used (though convenient) did not outweigh the broken behavior they exhibit, hence their removal in v3.

Use this module at your own risk, or better yet, not at all.

Provided number methods

  • number#increment
  • number#decrement
  • number#$inc
  • number#$dec


  • mongoose-number 0.0.2 is compatibile with Mongoose >= v3.0.0 < v3.6.0
  • mongoose-number 0.1.0 is compatibile with >= Mongoose v3.6.0