Exercise Tracker exrecise - Very unclear on what do to

Hi everybody

I’m having a terrible time with the Exercise Tracker exercise, this one:

I’m still in the /api/users/:_id/exercises section.

I got Mongo working with Mongoose, but I’m very, very unclear on what I need to return here. Do I need to have a separate Exercise schema? That would be a different collection in the database.
Do I need to the unite it somehow with the user?
Should each user somehow have its own “collection” of exercises? Is that even possible in a non-relational db?
Or should all the exercises just live in a big collection, and each would be associated with a specific user (because it would contain a username field)?

I’ve tried to use “findByIdAndUpdate” to add the exercise fields (from the form) to the user document, but it failed miserably. It took me two hours to understand that findByIdAndUpdate doesn’t add new fields, it only updates existing fields. The mongoose documentation doesn’t say that, of course (terrible documentation).

Some assistance or guidance would be very appreciated.

Thank you!

Follow the specifications for responses returned.

Yes, all these arrangements are possible. They are design choices and you can make any of them work. The need for separate schemas depends on the choices you make here.

Be systematic. Get the user tests passing. Create the routes so that they log their name, all route inputs, and all route responses and run the fCC tests against your running server. Decide how you want to store the exercise data, typically either as separate exercise documents linked by the user ID or as an array on the user data. Then use the same logging and testing routine to pass the exercise posting tests. Then work on the exercise logging tests in the same manner.

If nothing else, you can start by creating routes at all the required endpoints that log the route names and inputs and then logs and responds with a dummy response and fill in the blanks as you can.

Thanks @jeremy.a.gray for your answer. That’s essentially what I did, though I peeked at existing solutions to see whether I was on the right track.

I ended up putting all the exercises in their own collection, and they are associated with the user only by their “username” field - that is, associated only by the field (instance member?) they contain, but structurally they are all in one big collection.

So, the code is now a bit messy because there I haven’t set up an Express Router (will try to do that tomorrow), but I’m in a curious situation where, when I submit the localhost link to the FCC challenge, I get all tests passed. But when I submit the replit, it does work, but this test fails:
" The dateproperty of any object in thelogarray that is returned fromGET /api/users /:_id/logsshould be a string. Use thedateStringformat of theDate API."

If I change nothing, and submit the localhost link, it passes, but I can’t submit to formally finish. What’s the problem?
This is the replit - the line that specifically target this test is on line 116 - it should do the trick but it doesn’t. Any thoughts?

Thank you!

Just to update - the code was correct. It was the timezone difference that made it fail that test. It was past midnight where I live, and the test tried to validate its own time, which was one day earlier than my timezone.

Leaving this here as a solution for future students. Thank you @jeremy.a.gray for trying to help.