Ticket: Get Comments - Test is not passing

Even though the implementation is correct, the test isn’t passing. I keep getting these errors.
Thank you so much for any help!

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

It is not.

Your pipeline produces a field named movies_comments while the requirements ask for a field named comments. That is why you get **Cannot read property ‘length’ of undefined.

1 Like

Thanks, Steevej! You’re right. I found the same answer in another post a couple minutes ago.
Problem solved with “comments” as field name.
Thank you again!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.