Get Column Metadata

Get the Metadata of a Specific Column

You can obtain the metadata of a single specific column of a Data Store table of the given instance by calling the getColumn() method. If the operation is successful, this method can return the metadata of the column, such as its data type, default value, or maximum length, or whether it is read only, unique, or mandatory.

The metadata of a specific column can be fetched in two different ways. The <TABLE_INSTANCE> used in both the methods is the instance defined in the Table Instance page.

i. Get a Column by its ID

You can retrieve a specific column’s metadata by passing the column ID as the argument to the getColumn() method in the String format, as shown in the code structure below:

    
copy
Future<(APIResponse, ZCatalystColumn)> <TABLE_INSTANCE>.getColumn(String identifier)

Parameters:

  • identifier: The unique Column ID of the particular column that needs to be retrieved

A sample code snippet is shown below:

    
copy
try { var (response, column) = await app .getDataStoreInstance() .getTableInstance('Projects') .getColumn('1624000000139101'); print(column.id) } on ZCatalystException catch (ex) { print(ex.toString()); }

ii. Get a Column by its Name

You can retrieve a specific column’s metadata by passing the column’s name as the argument to the getColumn() method, as shown in the code syntax below:

    
copy
Future<(APIResponse, ZCatalystColumn)> <TABLE_INSTANCE>.getColumn(String identifier)

Parameters:

  • identifier: The name of the particular column that needs to be retrieved

A sample code snippet is shown below:

    
copy
try { var (response, column) = await app .getDataStoreInstance() .getTableInstance('Projects') .getColumn('Category'); print(column.id); } on ZCatalystException catch (ex) { print(ex.toString()); }

Get the Metadata of all Columns

You can retrieve the metadata of all the columns of a table of the given instance, using the getColumns() method, as shown in the code syntax below. If the operation is successful, this method can return the metadata of all the columns of the specific table.

The <TABLE_INSTANCE> used in the code below is the instance defined in the Table Instance page.

    
copy
Future<(APIResponse, List<ZCatalystColumn>)> <TABLE_INSTANCE>.getColumns()

A sample code snippet is shown below:

    
copy
try { var (response, columns) = await app .getDataStoreInstance() .getTableInstance('Projects') .getColumns(); for (var column in columns) { print(column.name); } } on ZCatalystException catch (ex) { print(ex.toString()); }

Last Updated 2024-09-12 18:16:13 +0530 +0530