Decimal / Float in mongoose for node.js


I start my first test app on node.js / mongoDB / mongoose, this is a very simple app that aims to crate record in DB and retrieve them.

I create a model like:

var Car = new Schema({
    brand : String,
    speed  : Number,
    date  :  { type: Date, default: }

This is working fine, except that I would like to be able to provide a float value for speed instead of the integer one. I gave a try to Decimal and Float but none of them are working. I did not find in the documentation either.

Any idea ?

4/9/2011 2:14:15 PM

Accepted Answer

I am not familiar with mongoose and node.js at all, but I've searched a bit and found that for storing float values you must use Number type. You can store any float value in speed field. Article.

Hope this help.

1/30/2014 12:46:41 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow