findByIdAndUpdate return null

Hello, I’m running into issues with test 7 and 9 of the PUT queries, I think it’s related to the fact that for some reason, when I call the findByIdAndUpdate method, it’s not actually updating the updated_on field. When I console log the response, it’s receiving null. I’ve gone about a week tweaking code, reading documentation, and scouring the web, but haven’t found the right solution yet and I’m at my wits end. Plz halp

The flow of info I’m trying to code in the PUT route is:
Verify the _id exists
Verify there are fields to update
Take the parameters from the query, leaving the blank ones out
Correct the “open” or “closed” from the query from string and convert to Boolean
Add updated_on with a new Date. (console log of params show the fields to update)
Find the ID and update it (this is where I receive null)
return with a json message saying successfully updated.

Receiving the following errors:
[Error: expected 1688995545147 to be above 1688995545147] – I think this is the timestamp, showing it’s expecting the time to be later but it’s not.
[Error: expected { Object (result, _id) } to deeply equal { error: ‘could not update’, …(1) }] — This may be unrelated to the first issue, but there may be another underlying issue because manually, the updates no longer process.
[Error: expected { status: ‘unavailable’ } to be an array]

I’ve tried Inspect Element of the fCC test page itself and I’m struggling to understand how to link the console errors to something in my code to edit, as I don’t understand the code in the references that the console points to in the DevTools.

Describe your issue in detail here.

Your project link(s)

solution: boilerplate-project-issuetracker - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Quality Assurance Projects - Issue Tracker

Link to the challenge:

Thank you!!!

I never ended up figuring out the cause of this specific problem, I ended up rewriting the code and going a different route.

Originally I had a document (project) and the issues were created as subdocuments, but I had trouble getting access to the subdocs afterwards. So I rewrote and made projects names a part of each issue’s Schema. Learned a ton about Mongoose while troubleshooting though!

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