Why are numbers being inserted into MongoDB incorrectly?

50 views Asked by At

I'm working on my first application and ran into something I can't figure out. While making a call to an external REST API I get a response that I parse into JSON, then insert into MongoDB.

When logging the parsed response into console, I'll get expected responses that look like this:

{ "userkey": 1265305129852079875, "datakey": 5436379464010906368 }

When I look in MongoDB, the data now looks like this, where the numbers rounded up?

{ "userkey": 1265305129852079900, "datakey": 5436379464010907000 }

After hunting around I can see that these are being inserted as BSON type double, but I'm not entirely sure what this means or how to get my result to save as I see it in the console.

0

There are 0 answers