I have a table that for each player have an array that contains PlayerIDs as a list of player possible opponents
Currently when i click on a player ot shows a list of potential opponents and this works nice.
I am thinking on providing better UI to users by providing possible pairs so my collections displays
Player1,Player2
Player1,Player3
Player2,Player4
With their names and photos
In order to do this I need to:
Create an new array of pair arrays 
Column: subarray1 (P1,P2), subarray2 (P1,P3), subarray 3 (P2,P4)
I can do this with js column or some easier way?
When I create such an subarray, is it possible to create relation for such array of arrays to maon players table to lookup for player names and photos so the pair is displayed clearly.
Assuming this is the structure (or in the second column, you can use a joined list to get it to look like that if you’re having an array).
return p2.split(',').map(element => p1 + ' - ' + element).join(', ');
Here’s the JS code needed to return the strings in the final column.
Then, add a helper table column. You have to add as many rows beforehand as needed to store the matches.
I think your case is a bit more complex reading your other thread, with time slots etc, but this should be enough to get you started. You can use 2 further JS columns to get the player’s IDs and then do relations/lookups to get names & photos back.
2 Likes
First of all, @ThinhDinh thank you for the effort of helping me.
I had something similar on mind (playing with strings, like your first step).
This approach won’t work for me - as it requires creating additional table to store matches.
My app is dynamic and I cannot create helper table to add rows dynamically. Maybe this is possible by using Glide API, but I am on the Maker plan.
Currently, I can only represent possible matches for a time slot by creating custom collection that sources TimeSlot table and displaying PossibleMatches joined list as string (without photos and nice layout).
Can’t you just add enough rows up front to cater for the maximum number of expected permutations?
I use Helper Tables in every App that I build to help produce dynamic content, but I’ve never added or removed a row to a Helper Table with an action.
I can add rows upfront. Would that work for my case. Not sure I understood your idea then
Now i got it how it works.
Basically you created helper table and made a relation to itself by rowID. Then lookup to ensure you how all rowIDS in IDs column
Then added index.
Then lookup to all possible matches converted them to array and used index to isolate the match in a nee column.
I can now split the match pair into player1id amd player2id and link them to main players table to obtain player daya
Genial! Thanks!
2 Likes
Great to hear
That hasn’t solved your “unique” matchup problem you mentioned in the other thread though.
Easy to solve unique.
When splitting possible matches in step 1 always make sure the same pair is in format
Player1 - Player2
So instead of Player2 - Player 1 I will have
Two pairs Player1 - Player2
Then will do Array unique elements and get rid of redundancy before continuing with the rest of your steps
1 Like