Get Column Metadata
Column metadata details of a single column can be retrieved through the following methods. The table used in the below code snippets is the table object.
Get Column object by ID
To fetch a column's meta data of a particular table using Column ID, you need to create a column object at first, which would not fire a server side call.
Copied//Get The Column Object using Column ID
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
Copied{
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"
}
Copied{
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 object by Name
Alternatively, you can use the Column Name to create a column object.
Copied//Get The Column Object using Column Name
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
Copied{
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"
}
Copied{
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.
Copied//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
Copied{
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"
}
Copied{
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 all the Columns
In addition to getting the metadata of a single column, you can retrieve the meta data of all the columns of a particular table using getColumns() method. The table used in the below code snippet is the table object.
The promise returned here is resolved into an object in which the content key contains array of column meta details.
Copied//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
Copied[
{
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"
}
]
Copied[
{
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
}
]