parse-server
parse-server copied to clipboard
Add support for Mongo's Decimal128 data type
New Feature / Enhancement Checklist
- [x] I am not disclosing a vulnerability.
- [x] I am not just asking a question.
- [x] I have searched through existing issues.
Current Limitation
Current Parse Server "Number" data type only supports numbers up to Mongo's double data type max value
Feature / Enhancement Description
Mongo 3.4 added support for Decimal128, adding support for it would allow servers to store numbers that they couldn't store before, all while keeping all query functions still working (afaik Decimal128 supports $gt, $gte, $lt, $lte, $eq, etc...)
Implementation I think would be very straightforward, the problem with this data type that it's not natively supported in all SDKs, so Parse Server would probably need to send the Decimal128 as a string in the Response and the SDK would need to convert the string back to a BigDecimal class (probably available in all languages)
Another problem is to find another alternative for Postgres, but I am no expert in Postgres so idk..
Example Use Case
I think any app that deals with monetary values need this data type, most blockchains use uint256 (max value of 2^256-1) for value representation...
Alternatives / Workarounds
You can store big numbers using strings right now, but that doesn't support number specific query functions...
References
https://www.mongodb.com/developer/products/mongodb/bson-data-types-decimal128/ https://github.com/iriscouch/bigdecimal.js/tree/master https://pub.dev/packages/decimal
Thanks for opening this issue!
- 🎉 We are excited about your ideas for improvement!
How would you imagine to implement this? With a new { __type: "decimal128", value: "..." }
? And what should the type be called, bigdecimal
, decimal128
,..?