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, maximum length, or whether it is read only, unique, or mandatory.

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. The <DATA_STORE_INSTANCE> used here is the instance defined in the Table Instance page.

    
copy
<DATA_STORE_INSTANCE>.getColumn( id : Int64, completion : @escaping ( Result< ZCatalystColumn, ZCatalystError > ) -> Void )

Parameters:

  • id: The unique Column ID of the particular column that needs to be retrieved
  • completion: If the operation is successful, the completion block will return the column details. Else, it will return an error.

A sample code snippet is shown below:

    
copy
ZCatalystApp.shared.getDataStoreInstance(tableIdentifier : String).getColumn(id :1096000000002459 ) { ( result ) in //Replace this with your column ID switch result{ case .success ( let column) : print(column.name) case .error( let error ) : print( "Error occurred >>> \( error )" ) } }

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 <DATA_STORE_INSTANCE> used in the code below is the instance created earlier in the Table Instance page.

    
copy
<DATA_STORE_INSTANCE>.getColumns( completion : @escaping ( Result< [ ZCatalystColumn ], ZCatalystError > ) -> Void )

Parameters:

  • completion: If the operation is successful, the completion block will return the details of all the columns in the table. Else, it will return an error.

A sample code snippet is shown below:

    
copy
ZCatalystApp.shared.getDataStoreInstance(tableIdentifier : "EmployeeDetails").getColumns{ ( result ) in // Replace this with your table name switch result { case .success ( let columns) : for column in columns { print(column.name) } case .error( let error ) : print( "Error occurred >>> \( error )" ) } }

Last Updated 2023-09-14 18:05:46 +0530 +0530