Trying to understand Retool MySQL Select query response

  • Goal: Show users in a custom form

  • Steps: Create a Query, show data in the table and create a custom form without

  • Details: I am firing a plain SELECT query and expecting that the data will return in an Array e.g.

    	"name": "John",
    	"age": 28
    	"name": "Baron",
    	"age": 32

instead, when I do, I see that each field is wrapped in a array e.g.

    "id": [1,2],
    "name": ["John", "Baron"],
    "age": [28, 32]

See the screenshot below for actual response.

So when I have to assign default value to a Custom Field, I have to use the following syntax:[0]

instead of a normal way:[0].name

Is this the way data is actually handled in Retool or there is some problem?

  • Screenshots:

1 Like

Welcome to the forums!

The query result is as expected, but you can also access the data as an array by using queryX.dataArray instead of if you prefer.

Let us know if that helps or if you need something else!

1 Like

In addition to @jg80 response, you can also transform your query's data at the source by enabling the transform results section and using the helper formatDataAsArray (data). With this you will see your results as you were expecting

formatDataAsArray does the trick for me!