mongoose-double

Double support for Mongoose

#mongoose-double

Provides Double support for Mongoose.

Example:

var mongoose = require('mongoose')
require('mongoose-double')(mongoose);
 
var SchemaTypes = mongoose.Schema.Types;
var mySchema = new Schema({ double: SchemaTypes.Double });
var Xaction = db.model('Xaction', mySchema);
 
var x = new Xaction({ double: 47758.00 });
 
x.save(function (err) {
  Xaction.findById(x, function (errdoc) {
    console.log(doc.double.value);
    doc.double.value += 484.134;
    doc.save(cb);
  });
});

Values are cast to instances of Double. The value you pass is stored in the doubles value property.

x.double = 40;
console.log(x.double)       // { _bsontype: 'Double', value: 40 } 
console.log(x.double.value) // 40 
 
// or use `valueOf()` 
console.log(x.double.valueOf()) // 40 
npm install mongoose-double

See node-mongodb-native docs on all the Double methods available.

LICENSE