Trouble with "Ticket: Create/Update Comments"

I’m having trouble with the “Ticket: Create/Update Comments” in #M220P
I have modified db.py and now I’m able to create comments and update then in the “site” but when I go to the verification in [STATUS] button I get this Message:

“Create/Update Comments: Unable to update comment” (in red)

Any help would be appreciated

What is the error message in console?

Also, are the unit test case passing?

Kanika

Thank you @Kanika

The problem was that the comments were not sorted (newer first).
Took me hours to debug this one.
The task description should be more clear.

For the future coders, don’t even try to order the comments array of documents in the pipeline. Do it in Perl after the result is fetched.

Hi @fenetto,

Thanks for the feedback. I will make sure it gets clearer in the instructions. :slight_smile:

Kanika

For the furure coders, do not follow the advice of using perl.

Think about the following.

You want the n-most recent comments as clearly indicated in the requirements. Let say you have 10000 comments. Then every time somebody use your app you will download 10000 comments from the server just to get rid of most of them. Better have the server do it. In addition, if you have an index on the date the server does not even have to fetch the comments from storage to do the sort and limit required to get the n-most recent.

And do not forget that you are here to learn mongo. You are not here for a grade. If it take a few hours to understand a concept, well that’s the price to pay.

1 Like

I agree with @steevej-1495
And its doable if you don’t use $lookup as Compass default.
Use $lookup with pipeline.
Sorry for the bad advice