How to reference the same query that is being used?

Hello!

I'm currently working on a query error tracker. So whenever there's an error, the information gets inserted into a table at the retool database. So I'm trying to see what's the best way to move forward by doing some experiments.

Currently the best way I've thought about is to add a function to every query that I want to track so if something fails, it gets triggered. Which looks as follows:

image

But I have two questions:

1.- Could I self-reference the same query so instead of putting error: query1.data I would instead write something like error: this.data so that I can easily copy the script to all of the other queries that I need to track? (I already try with this but it didn't worked so I'm not so sure if I could self-reference the query that's being used)

2.- Is this a good way to accomplish what I'm trying to do? I've been following other posts in the community which are trying to accomplish the same thing but there are some gaps which I haven't been able to figure out how to do by myself based on the information provided.

I'll continue experimenting, but regarding the first question, that's something I haven't found an answer yet on my own, whether it's on the docs or in the forum. So any help would be greatly appreciated.

Hi, you can reference the query itself with self

also there is a related post, might be helpful

1 Like

Thank you so much! I completely forgot about self. I've used it plenty in components but never before in queries so that didn't cross my mind, but it was indeed the solution.

Also thanks for sharing the post on catching unexpected bugs. I've been looking more into it, but I think it's more of a second thought rather than the main question of this post. So I'll mark it as solved. Regardless any feedback on the idea would still be hugely appreciated :grin: If I get stuck on something I'll make another post.

1 Like