I have a collection of People, and I have a collection of Events. Each Event has a set of speakers, who are People. (1:N relation)
I have a dataset in the event page to get the speakers for that event; that’s all good. I have a repeater to show them. But I’d like to sort them in a specific order for the Event: one is the main speaker; they should come first.
Is there any way to sort a query using code, or a computed field, rather than just using the db fields? (One person may be the main speaker for one event, but not for others, so I can’t add things to the People table for this.)
I can add something to the Event, like a string field with all the speaker names comma-separated or something, so I know what order I want them in, but I can’t figure out how to tweak the query. I have no problem writing as much Javascript as needed for this.
I see there is an AfterQuery hook, but it looks like that runs after the whole query, including the sort, so I don’t think I can add a computed field there and then sort on it.
Is there perhaps a way to reorder the repeater elements in the DOM? Or any other clever ideas? Could I have a separate collection that maps events to speakers in order somehow (like a relation table)? Any help appreciated, thanks!