I am new to Retool. I am using Query Json with SQL option to return data from MongoDB.
It is working fine, however I want to add one message, if no data is there in DB for search. I believe need to write transformer.
Below is my query:
select
product,
expressions,
concat_ws(',',field_names) as field_names
from
{{ResultValidationMapping.data}}
where
CASE LEN({{textInput1.value}})
WHEN 0 THEN field_names = field_names
ELSE {{textInput1.value}} in field_names
END
Welcome to the forum!
Since you're using Query JSON with SQL, there would not be a request against the database so there isn't a message coming from there. Instead you can use the Success Event handler and add logic that says if there is nothing returned then do something (open a notification, etc.)
You're using Success because technically, the query you're running won't fail. At least as far as I can see...
You can also use a Transformer to check the data and if nothing is found you can set the data to a message saying No Configuration found and the populate whatever component you want to display the message in with that data.
Continuing on what @ScottR mentioned here, you really shouldn't change the output of the query rather create states that manage these conditions in your UI.
Not aware of your exact use caser but if you just need to check if a query is empty you can use:
Thanks for your reply. As I mentioned I am very new to this tool, I am not sure what do you mean by states.
I'll explain what I am trying to do.
I am using Query JSON with SQL and written query and binded to grid. Till this point it is working fine.
Now I want to display "No Configuration Found" message, if there is no records in DB, to achieve that i have enabled Transformer which is below my query.
Please find below screen shot for the same, so this you will get fair idea.
If you only want to display that message in your Table (grid) you can set the "Empty State" value of your table to "No configuration found". You don't need a transformer at all for this.
Check out your table component -> Data -> Empty State.