mongoose-double

Double support for Mongoose

npm install mongoose-double
5 downloads in the last day
15 downloads in the last week
87 downloads in the last month

mongoose-double

===============

Provides Double support for Mongoose.

Build Status

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 (err, doc) {
    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

install

npm install mongoose-double

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

LICENSE

npm loves you