Create or Update Comments

i had been trying the addComment and updateComment task since few days, unable to pass the test, when i researched more i found that.
when i execute the below code for addComments
const commentDoc = { “text”: comment, “movie_id”: ObjectId(movieId), “name”:, “date”: date }

  • return await comments.insertOne(commentDoc)*
    the test is passing by providing the = postCommentResult.insertedId

but when i verified the DB the id is not generated at-all so, when i execute the update command there is no matching for id with email_id
for getMovieById() function, also giving the descending sorted order

how its going to pass the task, am seriously stuck , not able to find the solution.

updateComment code snippet

const updateResponse = await comments.updateOne(
{ “_id”: ObjectId(commentId), “email”: userEmail },
{ “$set”: { “text”: text, “date”: date } }

You try to update the command with a field named email but there is no such field in your collection because when you create the comment you are using “name”:


super nice catch steeve, how come i missed that part , how stupid am :slight_smile:
Any how thanks for the hint.

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