i'm new to mongoDB. I got my data as a string but i want to parse it to a decimal/ float.
I found made this code but it doesn't seem to work. This is my code, it replaces - for 00, * for "", and parses it a float. It gives no errors, but the parseFloat(doc).toFixed(2).
db.behuizingen.find().forEach(function(doc)
{
var price = doc.Prijs.replace('€', ''); // it may be vary for your other document
price = price.replace('-', '00');
price = price.replace('*', '');
doc.Prijs = Number(price);
parseFloat(doc).toFixed(2)
db.behuizingen.update({_id : doc._id} , doc;
})
Thanks in advance.