I have a database list of exercises and workouts. They have a many-to-many relationship.
When I create a workout and add multiple exercises to that workout, I would like to display the list of exercises for that workout in the order in which I added the exercises. Currently it automatically sorts it alphabetically (or reverse alphabetically).
Is there a way this can be changed to sort based on when which exercise was added first? Thanks in advance!
There are several other ways to sort, including by creation or updated date. But I like to add a number parameter to my collections, then sort by number. I call the field “sequence”.
This also make it easier to rearrange the order when necessary, something you can’t do when sorting by any other criteria.
And when I test the app and open that workout, the default list’s order is based on the creation date of the exercise list (rather than the order in which I added the exercises into the workout):
I know I can sort that exercise list within the workout alphabetically, by creation date (of the exercise list), and upload date (of the exercise list)…but I don’t know how to sort by any other manual way, for example if I wanted the workout list order to be:
1- Deadlift
2- Bench Press
3- Tricep Dip
Does anyone know if this is achievable or if there is a workaround? Thanks!
you can add a number property on the collection, give the exercice you wanna see first the number one and so on, then filter the list using that property,
But would you mind elaborating? I’m not sure I understand. Do I add a number property to the workout collection? How do I link that number property to the exercises that I select in that workout?
I think there is no way to sort it based on the user added way with relationships. But you could achieve this with creating another collection to store the exercises of that workout and sorting that list as Created Date- Oldest to Newest.
Made a quick clonable app :
And made a video too :
Jason ( @jasondupree ) made a wonderful Workout app and that app has this sorting and I think he also did the same way or maybe a different way!
@TrZd I did this with a “join table” collection. For a basic version of this, there’s 3 collections:
Workouts
Exercises
Workout Exercises
You don’t want to link exercises directly to workouts. Instead, link exercises to workout exercises, and workout exercises are linked to the workout. The workout exercise holds the data, like the order, sets, reps, rest, etc.