Hi,
I am getting this error while trying to run my code:
Error during migration, MongoParseError: URI malformed, cannot be parsed
Please find the code:
const predicate = { lastupdated :{ $exists :true , $type : “string”} }
//const predicate = { $or: [ { lastupdated :{ $exists:false } }, { $type: “string” } ]}
const projection = { lastupdated: 1 }
const cursor = await mflix
.collection(“movies”)
.find(predicate, projection)
.toArray()
const moviesToMigrate = cursor.map(({ _id, lastupdated }) => ({
updateOne: {
filter: { _id: ObjectId(_id) },
update: {
$set: { lastupdated: new Date(Date.parse(lastupdated)) },
},
},
}))
console.log(
“\x1b[32m”,
Found ${moviesToMigrate.length} documents to update
,
)
// TODO: Complete the BulkWrite statement below
const { modifiedCount } = await mflix.collection(“movies”).bulkWrite(
moviesToMigrate,(err, r) =>{
assert.equal(null, err);
})