Ticket: Create/Update Comments saving data in database

hi,
my code look like it is doing its job, but there is a problem in saving data in database.
any advise?

2

3

it passed when I set the expected value to ObjectId like that :
4

but it will not working in statues page,
I also tried to reload data sample and reset connection
any advise please?

Unit tests are supplied to verify that you implemented the requirements correctly.

When unit tests fail, the most likely cause of the failure is that you did not implemented the requirements correctly.

You do not modify the unit tests to match your code. If your code does not produced the expected values, then you fix your code.

You shared everything except your code, so it is hard to say what is wrong with your code. Your problem lies in either CommentsDAO.addComment() or MoviesDAO.getMovieByID().

1 Like

sorry because I didn’t share my code at first,
that is addComment():
addComment

and that is getMovieById():

An aggregation pipeline can contains a $sort stage.

The requirement is for sorting the comments within a movies.

By doing the sort outside the aggregation, like you did, you are sorting the movies (actually the only movie) rather than the comments. That is why the unit test fails. Your MoviesDAO.getMovieByID() does not return the comments in the correct order.