I have taken this course before, and have answered the Get Comments and Create/Update Comments tickets successfully, but this time, I am having some trouble.
My code this time was substantively similar to last time around, but even if I use the exact same code as last time, an error relating to the “new” keyword is thrown.
So, within usersDAO and commentsDAO, I changed instances of ObjectId() to new ObjectId().
When I did this for the getMovieById() problem, both the unit tests and status page validated. However, when I did this for the addComment() and updateComment() problems, the unit tests validated, but the status page gives me a “Create/Update Comments: Unable to post a comment” error.
I noticed when installing mflix, there is a new bson dependency in the node.js packages file. I suspect this has something to do with the issue.
I also noticed by looking in Atlas, that the total documents in the comments collection increases by 1 each time I run the unit test, while when I run the status validation page, it does not increase. I am not sure whether the non-deletion of comments inserted by the unit test will affect things. Also, in the node.js log, I get a 500 error when reloading the status page.
I have tried dropping and restoring the database, looking in the forums (where I notice there are various problems relating to this ObjectId() problem, but no solution seemed to do the trick for me) and looking at the related test js files to try to figure it out, but to no avail.
I am sure there is an easy solution here, or that I am missing something trivial relating to the above. I’ll post code if necessary for diagnosis though.