Get Column Metadata

Column metadata details of a single column of a table in the Catalyst Data Store can be retrieved through the following methods. The table reference used in the below code snippets can either be a table instance or a table meta.

Get a Column’s Metadata by ID

You can fetch a column’s meta data of a particular table using getColumnDetails() method.

    
copy
//Get The Column Object using Columnid var datastore = catalyst.table; var table = datastore.tableId("SampleTable"); var column = table.columnId(COLUMN_ID);

A sample response that you will receive for each version is shown below:

    
Web SDK
copy
{
table_id: "2305000000007003",
column_sequence: "5",
column_name: "CityName",
category: 2,
data_type: "varchar",
audit_consent: false,
max_length: "100",
is_mandatory: false,
decimal_digits: "2",
is_unique: true,
search_index_enabled: false,
column_id: "2305000000007725"
}
{
table_id: 2305000000007003,
column_sequence: 5,
column_name: "CityName",
category: 2,
data_type: "varchar",
max_length: 100,
is_mandatory: false,
decimal_digits: 2,
is_unique: true,
search_index_enabled: false,
column_id: 2305000000007725
}

Get a Column’s Metadata by Name

An alternative way to get the meta data of a column is, referring to the Column name. This returns the same response as that of the previous one.

The column meta will not involve any further operations. Therefore the promise returned here is resolved to a JSON object.

    
copy
//Get The Column Object using Columnname var datastore = catalyst.table; var table = datastore.tableId('SampleTable'); var column = table.columnId(COLUMN_NAME);

A sample response that you will receive for each version is shown below:

    
Web SDK
copy
{
table_id: "2305000000007003",
column_sequence: "5",
column_name: "CityName",
category: 2,
data_type: "varchar",
audit_consent: false,
max_length: "100",
is_mandatory: false,
decimal_digits: "2",
is_unique: true,
search_index_enabled: false,
column_id: "2305000000007725"
}
{
table_id: 2305000000007003,
column_sequence: 5,
column_name: "CityName",
category: 2,
data_type: "varchar",
max_length: 100,
is_mandatory: false,
decimal_digits: 2,
is_unique: true,
search_index_enabled: false,
column_id: 2305000000007725
} 

Get Column Metadata Details

To fetch the metadata details of a column, you must use any one of the column objects created in the previous steps which will return a promise.

The promise returned will be resolved to an object in which the content key contains the column metadata details.

    
copy
//Get The column details which in turn returns a promise var datastore = catalyst.table; var table = datastore.tableId('SampleTable'); var column = table.columnId(COLUMN_NAME); var columnPromise = column.get(); columnPromise .then((response) => { console.log(response.content); }) .catch((err) => { console.log(err); });

A sample response that you will receive for each version is shown below:

    
Web SDK
copy
{
table_id: "2305000000007003",
column_sequence: "5",
column_name: "CityName",
category: 2,
data_type: "varchar",
audit_consent: false,
max_length: "100",
is_mandatory: false,
decimal_digits: "2",
is_unique: true,
search_index_enabled: false,
column_id: "2305000000007725"
}
{
table_id: 2305000000007003,
column_sequence: 5,
column_name: "CityName",
category: 2,
data_type: "varchar",
max_length: 100,
is_mandatory: false,
decimal_digits: 2,
is_unique: true,
search_index_enabled: false,
column_id: 2305000000007725
}

Get Metadata of All Columns

In addition to getting the meta data of a single column, you can retrieve the meta data of all the columns of a particular table using getAllColumns()method.

Note : The promise returned here is resolved into an array of column meta details.
    
copy
//Get all the columns in the table which in turn returns a promise var datastore = catalyst.table; var table = datastore.tableId('SampleTable'); var allcolumnPromise = table.getColumns(); allcolumnPromise .then((response) => { console.log(response.content); }) .catch((err) => { console.log(err); });

A sample response that you will receive for each version is shown below:

    
Web SDK
copy
[
{
table_id: "2136000000007781",
column_sequence: "1",
column_name: "ROWID",
category: 1,
data_type: "bigint",
audit_consent: false,
max_length: "50",
is_mandatory: false,
decimal_digits: "2",
is_unique: false,
search_index_enabled: false,
column_id: "2136000000007784"
},
{
table_id: "2136000000007781",
column_sequence: "2",
column_name: "CREATORID",
category: 1,
data_type: "bigint",
max_length: "50",
is_mandatory: false,
decimal_digits: "2",
is_unique: false,
search_index_enabled: true,
column_id: "2136000000007786"
},
{
table_id: "2136000000007781",
column_sequence: "3",
column_name: "CREATEDTIME",
category: 1,
data_type: "datetime",
max_length: "50",
is_mandatory: false,
decimal_digits: "2",
is_unique: false,
search_index_enabled: true,
column_id: "2136000000007788"
},
{
table_id: "2136000000007781",
column_sequence: "4",
column_name: "MODIFIEDTIME",
category: 1,
data_type: "datetime",
max_length: "50",
is_mandatory: false,
decimal_digits: "2",
is_unique: false,
search_index_enabled: true,
column_id: "2136000000007790"
},
{
table_id: "2136000000007781",
column_sequence: "5",
column_name: "CityName",
category: 2,
data_type: "varchar",
max_length: "100",
is_mandatory: false,
decimal_digits: "2",
is_unique: true,
search_index_enabled: true,
column_id: "2136000000008503"
}
]
[
{
table_id: 2136000000007781,
column_sequence: 1,
column_name: "ROWID",
category: 1,
data_type: "bigint",
max_length: 50,
is_mandatory: false,
decimal_digits: 2,
is_unique: false,
search_index_enabled: false,
column_id: 2136000000007784
},
{
table_id: 2136000000007781,
column_sequence: 2,
column_name: "CREATORID",
category: 1,
data_type: "bigint",
max_length: 50,
is_mandatory: false,
decimal_digits: 2,
is_unique: false,
search_index_enabled: true,
column_id: 2136000000007786
},
{
table_id: 2136000000007781,
column_sequence: 3,
column_name: "CREATEDTIME",
category: 1,
data_type: "datetime",
max_length: 50,
is_mandatory: false,
decimal_digits: 2,
is_unique: false,
search_index_enabled: true,
column_id: 2136000000007788
},
{
table_id: 2136000000007781,
column_sequence: 4,
column_name: "MODIFIEDTIME",
category: 1,
data_type: "datetime",
max_length: 50,
is_mandatory: false,
decimal_digits: 2,
is_unique: false,
search_index_enabled: true,
column_id: 2136000000007790
},
{
table_id: 2136000000007781,
column_sequence: 5,
column_name: "CityName",
category: 2,
data_type: "varchar",
max_length: 100,
is_mandatory: false,
decimal_digits: 2,
is_unique: true,
search_index_enabled: true,
column_id: 2136000000008503
}
]

Last Updated 2023-11-14 13:20:49 +0530 +0530