I am currently learning and applying MongoDB for a small financial related project.
When I read MongoDB in Action, it says:
The only other issue that commonly arises with BSON numeric types is the lack of decimal support. This means that if you’re planning on storing currency values in MongoDB, you need to use an integer type and keep the values in cents.
My financial related product will involve some currency values, but I am little bit confused or worried about the above statement. Here are my questions:
- Can I use
double
for thosecurrency values
in my project? - What will happen or is the consequences if I directly use
double
for them? - If decimal type is an must-have thing for financial product, is that a bad idea to use MongoDB?
- What does it mean
you need to use an integer type and keep the values in cents
? Does it mean that if I am going to store1.34 dollars
, then I should store134 cents
?