misha-ignatenko / stocks-react

0 stars 0 forks source link

Convert addedOn in RatingChanges to dates #34

Closed misha-ignatenko closed 2 years ago

misha-ignatenko commented 2 years ago

sample script:

var $lte = '2016-03-01'; var $gt = '2013-05-01';
// count of documents to fix
RatingChanges.find({dateString: {$lte, $gt}, addedOn: {$type: 2}}).count()
// convert strings to dates
RatingChanges.find({dateString: {$lte, $gt}, addedOn: {$type: 2}}, {limit: 19000, fields: {addedOn: 1}}).forEach(rc=>{var newD=new Date(rc.addedOn);console.log(rc._id,rc.addedOn,newD);RatingChanges.update(rc._id, {$set: {addedOn: newD}})})
// count the number of correct records
RatingChanges.find({dateString: {$lte, $gt}, addedOn: {$type: 9}}).count()