Get Table Metadata

Get Metadata of a Specific Table

The metadata of a single specific table in the Data Store can be obtained by calling the getTable() method. If the operation is successful, this method can return the metadata of the table such as the details of all the columns in the table, the table scope, the details of the individual that created the table, its last modification details, and more.

The metadata of a specific table can be fetched in two different ways. The <DATA_STORE_INSTANCE> used in both the methods is the instance defined in the Data Store Instance page .

i. Get a Table by its ID

The meta data of a table of the given Data Store instance can be fetched by passing the unique table ID as the argument to the getTable() method, as shown in the code structure below:

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

Parameters:

  • id: The unique table ID of the specific table to be retrieved.
  • completion: If the operation is successful, the completion block will return the table details. Else, it will return an error.

A sample code snippet is shown below:

    
copy
ZCatalystApp.shared.getDataStoreInstance().getTable(id : 1096000000002071) { ( result ) in //Replace this with your table ID switch result{ case .success ( let table) : print(table.name) case .error( let error ) : print( "Error occurred >>> \( error )" ) } }

ii. Get a Table by its Name

Alternatively, you can fetch the meta data of a table of the given Data Store instance by passing the table name as the argument to the getTable() method, as shown in the code syntax below:

    
copy
<DATA_STORE_INSTANCE>.getTable( name : String, completion : @escaping ( Result< ZCatalystTable, ZCatalystError > ) -> Void )

Parameters:

  • name: The name of the specific table to be retrieved.
  • completion: If the operation is successful, the completion block will return the table details. Else, it will return an error.

A sample code snippet is shown below:

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

Get Metadata of all Tables

You can retrieve the metadata of all the tables in the Data Store of a Catalyst project using the getTables() method, as shown in the code syntax below. If the operation is successful, this method can return the metadata of all the tables of the given data store instance.

The <DATA_STORE_INSTANCE> used in the code below is the instance created earlier in the Data Store Instance page .

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

Parameters:

  • completion: If the operation is successful, the completion block will return the details of all the tables. Else, it will return an error.
    
copy
ZCatalystApp.shared.getDataStoreInstance().getTables { ( result ) in switch result{ case .success ( let tables): for table in tables{ print(table.name) } case .error( let error ) : print( "Error occurred >>> \( error )" ) } }