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
//Use Table Meta Object to get the column with column ID which returns a promise let datastore = app.datastore(); let table = datastore.table('ShipmentDetails'); let columnPromise = table.getColumnDetails(1510000000110832); columnPromise.then((column) => { console.log(column); });

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

    
Node JS
copy
{
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"
}
{
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
//Use Table Meta Object to get the column with column ID which returns a promise let datastore = app.datastore(); let table = datastore.table('SampleTable'); let columnPromise = table.getColumnDetails('newColumn'); columnPromise.then((column) => { console.log(column); });

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

    
Node JS
copy
{
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"
}
{
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.

The promise returned here is resolved into an array of column meta details.

    
copy
//Use Table Meta Object to get all the columns which returns a promise let datastore = app.datastore(); let table = datastore.table('SampleTable'); let allColumnsPromise = table.getAllColumns(); allColumnsPromise.then((columns) => { console.log(columns); });

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

    
Node JS
copy
[
{
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"
}
]
[
{
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-09-03 01:06:41 +0530 +0530