In my movies collection, I have a year field, which is a String (example: "year": "2010")
I want to update year in all my collection, changing it to an int so I can compare it to other int fields.
I tried the following:
db.movies.updateMany({}, {$set: {year: new NumberInt("$year")}})
which changes every year value to 0 (int), and not the string value converted to int.
I also tried db.movies.updateMany({}, {$set: {year: parseInt("$year", 10)}}), but it returns NaN everywhere.
I have been trying for a while now and I can't see what I'm doing wrong! Any help much appreciated :)