Ticket: Get Comments . $Lookup wrong movie in getMovieByID


I am trying to solve the exercise about getting comments with getMovieByID but I am getting the next error:

This is the code:

I have tried different solutions, for example with $lookup instead of lookup, but nothing seems to work. Would you know what I have done wrong?


@Carlos_42420 you might want to link your thread to the course and mention which lab.

1 Like

Did you add a match stage before lookup stage? Please share the whole code.


By the way, there’s nothing wrong with the $lookup. The problem lies somewhere else, so suggest you focus your efforts in other parts of your code and see if you can figure it out.

Hello Karinka and 007_jb,

Thank you for your comments. Here is the whole code:


This looks good to me. As suggested by @007_jb, please check somewhere you might have changed.

Also, testing the same pipeline on your dataset will confirm where the problem is lacking.



Hmm, I don’t know what I might have changed… Nevertheless I tried to do it everything from scratch and I’m getting another error:

The code:


How? Did you download the original file and copy the function?


Not the function but the whole file. I did the tickets previous to this one, then I put the code and tried my luck again. :sweat_smile:


Are you sure the other functions from previous labs are working? I hope there’s no dependency.

I’m not a JavaScript kinda guy but that error message looks like movie.comment is returning Null or hasn’t been set.


It looks like the previous functions work. :slight_smile:

Cool :slight_smile: I still think this is the problem.

Run the function using the movie_id from the test script and see if it returns a comment. I think it will return Null and there’s no length property for Null.

You are using as: 'movie_comments’, are you sure it is the correct name?

The unit test expects movie.comments.length.


Eagle-eyed @steevej-1495 :face_with_monocle:

1 Like


That was it!! It worked when I put as: "comments"

Reading again the definition of ‘as’ I don’t know why it was failing. If you analyse the schema of sample_mflix.movies, ‘movie_comments’ doesn’t exists… In any case, problem solved!

Thank you @007_jb, @steevej-1495 and @kanikasingla for you help!

1 Like

Great @Carlos_42420!

Thank you so much @007_jb @steevej-1495 for the great help here.