I am getting a number (e.g., 450000) as a result from a mongodb query. I want to format the number with a thousands separator (like currency) as 450,000.
Number: 1593324
Expected Output: 1,593,324
How can I achieve this in mongodb?
you can't achieve this in mongodb because this is not programming language.
But You can use:
variableName.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
and then call to store this string in database
example:
var test = 1593324;
test.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
and then output i m getting : 1,593,324
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With