Get all fields from the database


Hello, is there a way to know/obtain the schema of a table from the Toolkit? I mean get the list of fields along with their types? I know that it is possible somehow because I can see the fields list in ChartFactor Studio.

I would like to do something similar in a custom embedded application.


I needed to do the same thing some time ago. Looking through the documentation I found this get method to extract information from your chart. To get the conf of the fields you can use .get("source"). That will return an object with the source information including the fields.


Thanks, @gen_dev. Exactly what I needed. It seems that every chart takes care of bringing the schema to be used so I only need to do a very simple query and get the source data.


Actually the one with the information about the schema is the provider, and is shared with every visualization that uses it. This means that the schema is queried only once, so if you have 10 visualizations that perform different queries, but they all use the same source, the schema will be queried only the first time.

With this been said, if you just need the schema and nothing else, you can use your approach of creating a simple query with a count or something, or use the provider directly:

const provider = cf.getProviderByConfig({ name: 'Elastic' })
.request('source', 'ticket_sales')
.then(source => console.log('Source schema is', source))