Having issues with a simple Query all records function
I'm duplicating an already existing endpoint that gets a list of surveys that are sent to a coach by their athletes.
This new get request gets the surveys, but now I need it to only return surveys that are sent from athletes in a certain group. Athletes have a table reference for group, and there is a team_groups_id input that I'm using to set == to var:athletes_1.team_groups_id.
When I run this it doesn't return surveys by group, it returns ALL surveys sent to the auth'd coach - which is what I already have working.
Here's what it looks like:
input: integer: team_groups_id (frontend inputs group ID and then returns the surveys of that group)
Function stack is set up so that:
Get coaches as coaches_1 (for auth)
Get athletes as athletes_1 (field name: text, team_groups_ID | field value: input int, team_groups_ID)
Query all records from surveys as model with → custom query:
db:surveys.coaches_id == var:coaches_1.id (so coaches only see surveys that are sent to them)
AND
var:athletes_1.team_groups_id == input:team_groups_id (not working, but hoping to get this to only pull athletes of the inputted group ID.
any ideas where I'm going wrong?
Best Answers
-
So in your second condition, you have a variable that is not a part of the table you are filtering and input that is also not a part of the table you are filtering.
Here is an example: you have a table with fields A, B, and C. What you have in your second condition is D = E
So it's not affecting the query because the condition is not related to the table.
-
Got it working!
Answers
-
Hi,
Based on your input I can see that in your second condition, you are comparing the variable with input (var:athletes_1.team_groups_id == input:team_groups_id), so there is no db field involved by which query can filter the records.
If you can provide screenshot then maybe I will be able to help more.
-
Here is what the custom query looks like. If the input needs to be a db field what would I compare it to so that it's returning only the ID's that match the input integer?
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback