Provides Mongoose v2 sub-classed Number with atomic increment/decrement support
Provides Mongoose v2 Number support for Mongoose v3.
var mongoose = require'mongoose'require'mongoose-number'mongoose;var partSchema = num: 'MongooseNumber' ;var Part = dbmodel'Part' partSchema;var part = num: 47 ;partsavePartfindByIdpartpartnumincrement; // uses atomic $incpartsavePartfindByIdpartconsole.logpartnum // 48
In Mongoose v2 every number was cast to this custom type. This type was removed due to the following caveats:
Observe the result of
typeof a.n1. Its "object" not "number"! Next observe the direct comparison of two mongoose numbers,
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.
Mongoose >= v3.0.0 < v3.6.0
>= Mongoose v3.6.0