Cannot test mongo aggregation MongoError: Unrecognized pipeline stage name: '$set' Cannot test mongo aggregation MongoError: Unrecognized pipeline stage name: '$set' mongoose mongoose

Cannot test mongo aggregation MongoError: Unrecognized pipeline stage name: '$set'


The $set MongoDB Aggregation pipeline stage will work only for MongoDB versions 4.2 and above.

You can use the $addFields Pipeline stage instead.

$addFields: {            isUsersContent: {              $eq: ["$teacher._id", user._id],            },      }

Note: The $set Aggregation Pipeline stage is nothing but an alias $addFields stage