Getting error in get-comments test $lookup Pipeline

My pipeline implementation -
// TODO Ticket: Get Comments
// Implement the required pipeline.
const pipeline = [
{
$match: {
_id: ObjectId(id),
}
},
{
lookup : { from : "comments", let : {"id" : "_id"},
pipeline : [
{ $match : {$expr: {$eq: ["$movie_id","$$id"]}} },
{ $sort : {date: -1} }
],
as : “comments”
}
}
]
return await movies.aggregate(pipeline).next()

Your are posting in Java group but your code JavaScript.

1 Like

Please try using $lookup instead of lookup.

$lookup : { from : "comments", let : {"id" : "$_id"},

Kanika

Kanika , even with $lookup it’s not working.
Test are throwing following error:

● Get Comments › comments should be sorted by date

  • Solved

Kanika