Hi All
Hoping for some help with this problem… feels like I’m missing something obvious.
Essentially, I need to build a nested query on a dynamic page and output the results to a table on that same dynamic page.
I have two collections
teams
games
Where games has two fields that both reference teams …
games.homeTeam is linked to teams.title and
games.awayTeam is linked to teams.title
fyi …this site is for a basketball tournament, where each team will want to know all the games they are playing. I have a dynamic page for each team (that displays the players on the team, their captain, ect) which is generated based on the teams.title
I’m stuck on how to build the query … specifically on how to define teams.title within the query…
To replace IDs with actual objects, you should be using Reference fields (if you aren’t already). You can find additional information here:
If you have text fields with IDs now, you can just go and replace them with references. This will make it available in databinding, so you can actually bind fields from referenced items to the table (in your case team name and any other attributes of the team). There is an article explaining that here:
Now, you are using the API to populate the fields of the table. At this time, we don’t yet support the API way of including referenced object in the query (but we are working on making it available).
So, what you should do is instead of populating the table from data set via explicitly setting items from dataset to the table, is to bind the table directly to dataset and configure referenced item columns there.
So what you need to do is:
Add second dataset for the games. I named it gamesDataset .
Then add the following code to on ready handler of you dynamic dataset (note - you need to use eq for matching):
Nice solution for binding the dataset to the table! When this is completely finished, I’ll write up the entire issue as it seems to be a popular question.
I do have a problem with the filter. As it is written now, I’m getting back all records in the games collection, regardless of the value of thisTeam._id