How to store value like 1.00 as double in MongoDB using mongoose using node.js?

Viewed 111

I want to store the value 1.0, 1.1 (as double not string) like this in mongo DB but when using schema type number it stores 1.1 but not 1.0(it's converted into 1). double dataType not supports. When we update directly from Robo 3T its store 1.0 as double but not via mongoose

1 Answers

Add mongoose.Decimal128 in the schema.

const vehicleSchema = new Schema({ fuelLevel: mongoose.Decimal128 });
Related