Not a user of the parsing server.
Adding an answer as it may be relevant for future mongodb users.
You can do this as follows, based on what you need.
You can make the server $lookup from the comments table to the connections table and check if it contains the user ID, the same as the current user.
Get all comments with favorite flag for current user
You can add the $addFields script to check whether each comment is liked or not by comparing the user ID with the current user.
db.commentcol.aggregate([ {"$lookup" : { "from" : "relationcol", "localField" : "_id", "foreignField" : "commentid", "as" : "commentusers" }}, {"$unwind":"$commentusers"}, {"$addFields":{liked:{$eq:["$commentusers.userid", user id]}}} ])
You should use the preserveNullAndEmptyArrays option when you $unwind save comments that no one likes, since the "commentators" from $ lookup will be empty in these cases
Get all comments liked by current user
Sort of
db.commentcol.aggregate({$lookup : {from : "relationcol", localField : "_id", foreignField : "commentid", as : "commentusers"}}, {$unwind:"$commentusers"}, {$match:{"commentusers.userid":current user id}}) .
$lookup + $unwind + $match optimized to use the index when there is one
Get all comments that the current user liked for a specific post
You can request a post with an identifier, then $lookup in the comments to get all the comments for this post, and then the above search to check if the current user likes the comments or not.
db.postcol.aggregate([{"$match":{_id:postid}}, {"$lookup" : { "from" : "commentcol", "localField" : "_id", "foreignField" : "postid", "as" : "comments" }},{"$unwind":"$comments"}, , {"$lookup" : { "from" : "relationcol", "localField" : "comments._id", "foreignField" : "commentid", "as" : "commentusers" }},{"$unwind":"$commentusers"} {"$addFields":{liked:{$eq:["$commentusers.userid", user id]}}}])