Create, Update, Delete Comments

Worth noting that the correct method is called ObjectId() not ObjectID (with capital I and lower case d).
I don’t know why my Atom suggested it with capital I and D and I was getting some error messages =)

For me, I was sorting the movies instead of the comments in getMovieByID.
If it helps someone, check your getMovieByID even if the tests are green.

1 Like

Thanks Juliettet. it solved my issue.

1 Like

this solved it for me, thank you!

The test fails

      const commentDoc = { 
	  
	  name:user.name,
	  email:user.email,
	  movie_id:  ObjectId(movieId),
	  text:comment,
	  date:date }
///////////
      const updateResponse = await comments.updateOne(
        {  email:userEmail, _id: commentId },
			{$set: { text: text,  date:  date} },
      )

Hi @Ahmed_42824

Are you sure you have the correct query criteria for your updateOne ?

Kindest regards,
Eoin

1 Like

The problem solved now it was in the getMovieByID function and fixed after sorting the comments.

1 Like

I am facing problem with comments tickets. How did you resolve the issue. When i console.log(commentId), getting the null value.

Hi @Nithin_01789

Can you provide a little more details / specifics on your particular problem ? What have you done and where exactly are you encountering the error ?

This will help us better understand your exact issue.

Kindest regards,
Eoin

Hi @Nithin_01789,

The main issue that I was having was related to the fact that (initially) my addUser() function was not implemented properly. This cause a chain reaction of errors in the comments ticket because without a user, there can be no associated commentId. Once I resolved that issue, everything else began to fall into place. Forgive me if what I’m saying doesn’t seem clear as it has been more than a few weeks since I have looked at my code for this course. I’m not sure if this is your issue, but I suspect that it may be. If not, make sure that you are assigning the commentId with the correct syntax (https://docs.mongodb.com/manual/reference/method/ObjectId/#ObjectId).

I hope that this helps:-)

1 Like