Addon default if record doesn't exist
This is probably more of a feature request, but is there an easy way to define a default if an addon to a query function doesn't contain a record?
Currently, the way that several addon types work (aggregate, single), if no record(s) were found it simply leaves out the field entirely. This is just annoying when it's a "single" type addon, since I would expect it to include the field with a null value instead. For aggregation, though, it means that if no records were found to aggregate, rather then including the record with a "0" value, or a "0" count, it just doesn't include the fields at all, which means I have to manually map and add those fields if they're missing every time I make that query.
It's really just an annoyance, but also counter-intuitive. Unless I'm missing something and there is an option to define a "if no record(s) return X" value.
I'm currently just wrapping the entire query in it's own function where I can handle the necessary manipulation, but I would prefer that the extra manipulation isn't even necessary.
Answers
-
Hello @sepirak-nick,
While what you want to do is currently not possible (as you correctly pointed out), an easy fix could be to have a default record on the table associated with the addon.A default record should be created in a way that satisfies all the conditions in your query.
Then in the front-end, knowing the content of the default record, you just ignore it, but you still get the fields.
-
Hi @sepirak-nick and @Lefteris - buynocodeapps.com ,
I have submitted a feature request if you want to upvote it.
https://xano.nolt.io/359
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