0

So I have a few fields that are currently strings that I am converting over to Double values in my mongo database. I was originally doing it with a find.forEach(function()).... style but that was taking way too long so I decided to try out the bulk operations Mongo has. So here is my attempt:

var bulkOp = db.transactions.initializeOrderedBulkOp();
bulkOp.find({"tran.val": {$exists: true}}).update(
    {
      $set: {"tran.val":parseFloat("$tran.val")}
    }
);
bulkOp.execute();

When I do this my tran.val which use to be "1.35" or something along those lines now becomes NaN. I also tried without the $ on tran.val but no luck. Am I missing something?

cadsdanaa
  • 29
  • 5
  • Tried NumberDecimal("$tran.val") instead and got: Error: Input is not a valid Decimal128 value. – cadsdanaa Feb 09 '18 at 18:12
  • Take a look [here](https://stackoverflow.com/a/34945977/2683814) as how to use bulk write and use NumberDecimal to convert values. – s7vr Feb 09 '18 at 18:15

0 Answers0