UPDATE
Since publication, it has been pointed out that there is alternative way of doing this without recourse to a custom extension.
Returning query[0].keys() for a multi record query, query.data[0].keys() with a paged query or query.keys() from a single record query in an API action produces the same results
i.e.
I recommend using this method over using this extension
Designed primarily to work alongside Wappler Intelligent Merge, this extension takes a query and returns the table schema i.e. list of fieldnames, as a comma separated list
(NOTE this does not currently work with a single record query or with paged queries )
So a query returning:
query: [
{
people_id: 1,
surname: "English",
forname: "Brian",
email: "brian@hyperbytes.co.uk"
},
{
people_id: 2,
surname: "Smith",
forname: "John",
email: "john@hyperbytes.co.uk"
}
]
would generate a comma separated list of
schema1: [
"people_id",
"surname",
"forname",
"email"
]
It is envisaged this will be used alongside Intelligent Merge to generate a "pick list" of available fields for use in an email template design stage in app connect. I am sure there will be other uses.
The extension can be found here:
and can be installed via this procedure:
Don't forget to restart Wappler fully to activate the extension.
The module will add a new icon to the "Database Actions" group
Simply add the action and add a query to the Input Data field
In this case i check output in query and the schema module and view the output in the browser
query: [
{
people_id: 1,
surname: "English",
forname: "Brian",
email: "brian@hyperbytes.co.uk"
},
{
people_id: 2,
surname: "Smith",
forname: "John",
email: "john@hyperbytes.co.uk"
}
]
schema1: [
"people_id",
"surname",
"forname",
"email"
]
}
The field names are returned as a comma separated list