Get Comments Ticket, Please help!

Here is my code:

const pipeline = [
{
$match: {
_id: ObjectId(id)
},
},
{
lookup: { from: 'comments', let: {"id": "_id"},
pipeline: [
{
$match: {
$expr: {
$eq: ["$movie_id", “$$id”]
}
}
},
{
$sort: {
“date”: -1
}
}
],
as: “comments”
}
}

  ]

I’m basically using the exact same code as the video, which after the video explanation, it makes sense. Although it’s not passing the “Can fetch comments for a movie test”. Somehow it is passing the second test (sorting by date). I’m just at a loss, I’m not seeing why it isn’t working… create a variable “id” that is essentially the _id from the movies collection, then use an $match filter to find where “movie_id” in comments is $eq (qual) to our $$id variable we created (starting to understand $$, but actually a little hazy on when and why to use just one $).

Most likely lookup is not written like that in the video:

So we are not supposed to touch the $match stage, am I right?

As noted on the well covered existing thread for Get Comments:

Watching the Video that comes directly before this question basically gifts you the answer, as the pipeline required is almost exactly the same. You should simply note that example adds something different to the last stage of the “inner” pipeline than what the question is asking you to add there.


You may need to watch the video on a large screen, which again has been noted elsewhere.

Anybody knows? Why it complains ‘let’? It did the same in the Compass! let|505x314

let

I would try to put let in quotes. In newer JavaScript let is a reserved keyword but I don’t know if in this context it can be treated as such. But it is worth a try.

a very detailed answer has been provided elsewhere!

Hi @steevej-1495. I believe the error comes from a missing bracket!