We are currently facing a challenge where one of our database tables contains columns with generic names (such as name, id, address, details_column_1, details_column_2, detail_column_3, …details_column_n). These column names are already being used by existing applications, so changing the table structure is not an option. This issue exists in more than one table.
The WEB API response for this table looks something like this:
{
name: ‘xyz’,
id: 123456,
address: [‘address lines’],
details_column_1: [],
details_column_2: [],
detail_column_3: [],
…
…
details_column_n: []
}
We are now attempting to create an interface model for this in Typescript, and as we add each similar item, the model keeps growing:
export interface ClientDetails {
id: number;
name: string;
address: array | null;
detail_column_1: array | null;
detail_column_2: array | null;
detail_column_3: array | null;
…
…
detail_column_n: array | null;
}
Is there a way to dynamically generate key-value pairs without hardcoding each value in the model file? We have around 50 columns like this and need a simple solution that does not require modifying existing application columns or responses.