Ticket Migration

This command does not appear to work for me.
$set: { lastupdated: new Date(Date.parse(lastupdated)) },

When I run it manually in the shell, I get the error: “ReferenceError: lastupdated is not defined”. Any clue to what I’m doing incorrectly? I’ve already got my predicate and projection set in the movie-last-update-migration script.

Can any one give some hint. whether i have to add some code in existing code or to remove some existing code then add some new code ?

Seems like you haven’t set the predicate correctly.

This basically means that “lastupdated” field was not found, which is de-structured from the cursor. So your cursor has some documents which should not be there.

If you set predicate correctly, then all documents which do not have this field will be omitted from the cursor and this error will go away.

1 Like

The HINT is that new Date("datestring") and Date.parse("datestring") are essentially the same thing, so you only need one.

See Date in an official documentation source.


NB As the documentation will note, using Date.parse() is not really good practice, and appears to be another result of a very Java rather than JavaScript background exposure exhibited by the original author of the code in this course.