I have a MongoDB (v 3.4.19) installed and running. After importing the data in .JSON format, one of the fields in the collection is recognised as string instead of the proper date or datetime format. I try to convert the fields, but what is my surprise after discovering that the fields with null values are filled with random (?) dates. I tried many different approaches, all of them without success. I wonder if any of you can give me a hand with this issue.
This is the code I have been using until now:
db.MIDAS_weather.find()
.batchSize(1000)
.forEach(function(doc) {
doc.METO_STMP_TIME=new Date(doc.METO_STMP_TIME);
db.MIDAS_weather.save(doc);
});
After importing the JSON files, the null values are in the right place. Is only after attempting the conversion when the data is messed.