Basic query filter
Hey there, for most of you, this is pretty obvious question, but as a beginner I've burned too much time on researching this, so here I am.
I have 2 tables. Rating request table and Ratings table. On my frontend I want to display only requests type1 that have less than 30 ratings and only rating requests type 2 that have less then 50 ratings.
Request Type is a separate column in Requests table.
How can I customize Get requests api call so it will be filtered based on these criteria?
Thanks
Answers
-
I suggest to do it simple.
- Add a
counter
integer field to the requests table. - Keep track of the number of ratings added/deleted related to each request by incrementing/decrementing each request counter field.
- QueryAllRecords
WHERE (type=type1 AND counter<30) OR (type=type2 AND counter<50)
- Add a
-
Thanks arturosanz, I was just wondering whether it could be possible without adding new column to request table.
-
It would be possible with two subsequent queries, one in ratings first and one in requests using the
intersect
filter in the second query with the results of the first one. But theintersect
filter is not available in the QueryAllRecords WHERE clause yet.Evals and aggregates are another more option. Perform a query on ratings joining the request, then add an eval aggregated field and sort the results by that field. Then loop through the results and remove from the array the ones that don't match your conditions.
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