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, as shown in the code syntax below:

    
copy
<TABLE_INSTANCE>.getColumn( id: Long, success: (ZCatalystColumn) → Unit, failure: ((ZCatalystException) → Unit)? ): ZCatalystRequest<ZCatalystResponse<ZCatalystColumn>>?

Parameters:

A sample code snippet is shown below:

    
copy
val table = ZCatalystApp.getInstance().getDataStoreInstance().getTableInstance("EmployeeDetails") //Replace this with your table name table.getColumn(2823000000017733, //Replace this with your Column ID { column -> println("Get Column success") println("The name of the column is: ${column.name}") }, { exception -> println("Get column failed! $exception") })

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
<TABLE_INSTANCE>.getColumn( name: String, success: (ZCatalystColumn) → Unit, failure: ((ZCatalystException) → Unit)? ): ZCatalystRequest<ZCatalystResponse<ZCatalystColumn>>?

Parameters:

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

A sample code snippet is shown below:

    
copy
val table = ZCatalystApp.getInstance().getDataStoreInstance().getTableInstance("EmployeeDetails") //Replace this with your table name table.getColumn("DepartmentName", //Replace this with your column name { column -> println("Get Column Success") println("The ID of the column is: ${column.id}") }, { exception -> println("Get column failed! $exception") })

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
<TABLE_INSTANCE>.getColumns( success: (List<ZCatalystColumn>) → Unit, failure: ((ZCatalystException) → Unit)? ): ZCatalystRequest<ZCatalystResponse<ArrayList<ZCatalystColumn>>>?

A sample code snippet is shown below:

    
copy
val table = ZCatalystApp.getInstance().getDataStoreInstance().getTableInstance("EmployeeDetails") //Replace this with your table name table.getColumns( { columns -> println("Get Columns success") for (column in columns) { println("${column.name}") } }, { exception -> println("Get Columns failed! $exception.") } )

Last Updated 2023-09-03 01:06:41 +0530 +0530