Ticket: Create comments

Mod Edit

Please do not post partially full implementations

I don’t understand why its not working. Someone help

@Adish_39279 Can you please edit your post and shift all the code over 4 spaces indented so it formats in a readable fashion. You should get used to this type of markdown formatting since it’s used everywhere else on the internet you might post questions in the future.

Also please just don’t post a “block of code” and just post the parts of code you are changing as well as explaining what exactly you don’t understand. You will also find that is also expected anywhere else on the internet where you want to ask a question of your peers.

Also note that BOTH the Status Page of the mflix application as used for the ticket submission and the unit test are looking at multiple functions to be implemented within the DAO section. So changing just one function is not sufficient to pass either test.

Please clean your post up, then also read the comments in the DAO which tell you what ticket and test they relate to and make sure you have done everything. Also be specific about what is failing and with any errors that may present as well.

Finally, please note the fundamental rule on the forum here. Nobody is supposed to post the answers. We can point you towards the right things to do only, since the real point of this is that you develop some skills in being able to reason the answers yourself.

In update function the tests are saying that expected 1 but received 0.
In addComment function the expected and received id are not same

@Adish_39279 Check the Status page on the mflix application. If the code is implemented complete then you will show a pass with the response code for the answer. If it is not complete then no response code will be shown at all. Generally this should be considered more reliable than the unit test implementation, and it’s also the only thing that counts towards your grade.

Note also that the verification of adding a comment uses code you should have added earlier for reading a movie with the “joined” comments.

Mod Edit

Please do not post screenshots that show validation codes for exercises. This defeats the purpose of them not being shown by default.

These are the cases that are passed

Screenshots really don’t help here ( and rarely do unless your question is about graphical layout ).

Read what you were pointed to already.

Also note that BOTH the Status Page of the mflix application as used for the ticket submission and the unit test are looking at multiple functions to be implemented within the DAO section. So changing just one function is not sufficient to pass either test.

You can see in screenshot the problem is with updating comment

Screenshots don’t help. You’ve basically been pointed at what do do short of just telling you the answer, which has already been explained as not what the forum here is for.

I’ll give one more HINT.

Go and look at the other already implemented code stubs. What do they do when you pass in an ObjectId or some “string” value which is meant to be an ObjectId?

Note they are NOT stored as “strings”. So standard reasoning is you need to “do something” and you already would have example code elsewhere which shows you what that “something” is.

1 Like

In many languages, if something is supposed to be an int but for usability or another reason isn’t of that type it’s common to cast the value, i.e. (int)foo or int(foo). As @neillunn has pointed out, you are leaving this step out on a particular field.

I’ve also edited your previous posts. Please do not post entire code blocks or screenshots of the validator page. This smacks of “just tell me the answer” rather than “please help me understand what I’m not doing correctly” and potentially cheats someone out of doing the work themselves if the answer is readily available.

I noticed that i have to cast the id but after casting it’s not working at all and not even a single test case is passing

Which test case is failing, and at which line?

All of the test case are failing as the id which us returned after adding comment is not same as what is expected and i think it is happening because of getComment ticket as in this ticked the test cases are failing but in mflix i am getting the code for getComments ticket

Last time I’m saying it. Please read what you have already been pointed to.




Are NOT the same.

Hence why you get different things returned and tests are not passing.

Spot the difference between those two and make the corresponding correction in your code.


This is really frustrating. I can’t even get the addComment function to pass the test and I know the commentDoc is correct. Ive tested adding the comment in mongo shell and it works.

Every ticket there seems to be an issue with the tests. Either often it fails in the terminal but passes on the status page. But this one… can’t get to pass any where. Can’t paste my code here obviously. So stuck.

1 Like
Expected value to equal:
- Expected
+ Received
- "5c6d917792ef043a783937d8"
+ "5b72217e20a327770964f954"

Same problem with me. I am also stuck on this ticket for some time

1 Like

can you paste your “commentDoc” object from addComment function?

Ok, after the meltdown yesterday I came back and looked at this with fresh eyes. If you have not sorted your comments in the ‘Get Comments’ ticket - then that test will pass on the status page (or at least it did for me) - but you won’t be able to pass the following two tickets (Create Comments and Delete Comments).

Going back and fixing the Get Comments ticket so the dates were sorted fixed this. Hope that helps. :+1:

yes, by fixing the get Comments ticket, my problem is also solved