mongoose-double icon indicating copy to clipboard operation
mongoose-double copied to clipboard

double type not working it store int instead of double bson?

Open byteab opened this issue 4 years ago • 5 comments

It stores int type instead of double.

import mongoose, { Schema } from "mongoose"
import Double from "../CustomTypes/Double"
export const ProductVariantEmbeddedSchema = new Schema({
  price: Double,
  discount: Double,
  isAvailable: Boolean,
  quantity: Number,
  maximumToBook: Number,
})

byteab avatar Jun 21 '20 07:06 byteab

Same here...

kaeferfreund avatar May 10 '21 21:05 kaeferfreund

solved by using decimal128

kaeferfreund avatar May 14 '21 20:05 kaeferfreund

This still seems to be happening. Any pointers on what to check in this code? I'm fine making a patch if no one is available actively maintaining this.

MattLJoslin avatar Sep 27 '21 01:09 MattLJoslin

Traced this down to the removal of valueOf. When I add valueOf back, the issue is resolved. I also have a very repeatable example to test with if anyone is interested. Will adding valueOf back break anything?

MattLJoslin avatar Oct 01 '21 01:10 MattLJoslin

Traced this down to the removal of valueOf. When I add valueOf back, the issue is resolved. I also have a very repeatable example to test with if anyone is interested. Will adding valueOf back break anything?

Hi @MattLJoslin , can you please provide pointers where we need to add valueOf. I am a beginner in this area. It would be of great help if you can share the code snippet.

abrahamp-hv avatar Jun 02 '22 05:06 abrahamp-hv