Get a Table Metadata
You can obtain the metadata of the tables in the Catalyst Data Store.
Get Metadata of a Single Table
You can pass the table's name or Table ID of the table to the get() method to fetch its metadata. The datastore and table instances used in the code snippet below are the component instance and the table object respectively.
This returns a promise which will be resolved to an object in which the content key contains the table meta details.
Copied//Get a single table's metadata
var datastore = catalyst.table;
var table = datastore.tableId('ShipmentDetails'); //Pass the table name or ID
var tablePromise = table.get();
tablePromise
.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{
"project_id":{
"project_name":"AlienCity",
"id":"2136000000007733"
},
"table_name":"AlienCity",
"modified_by":{
"zuid":"66466723",
"is_confirmed":false,
"email_id":"emma@zylker.com",
"first_name":"Amelia",
"last_name":"Burrows",
"user_type":"Admin",
"user_id":"2136000000006003"
},
"modified_time":"Aug 13, 2021 01:47 PM",
"column_details":[
{
"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"
}
Copied{
"project_id":{
"project_name":"AlienCity",
"id":2136000000007733
},
"table_name":"AlienCity",
"modified_by":{
"zuid":66466723,
"is_confirmed":false,
"email_id":"emma@zylker.com",
"first_name":"Amelia",
"last_name":"Burrows",
"user_type":"Admin",
"user_id":2136000000006003
},
"modified_time":"Aug 13, 2021 01:47 PM",
"column_details":[
{
"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
}
Get Metadata of All Tables
You can fetch the details of all the tables in a Catalyst project using getAll() method. The datastore and table instances used in the code snippet below are the component instance and the table object respectively.
This returns a promise which will be resolved to an object in which the content key contains the array of the meta details of all the tables.
Copied//Get metadata of all the tables in the project
var datastore = catalyst.table;
var allTablePromise = datastore.getAll();
allTablePromise
.then((response) => {
console.log(response.content);
})
.catch((err) => {
console.log(err);
});
A sample response that you will receive for each version is shown below:
Copied[
{
"project_id":{
"project_name":"AlienCity",
"id":"2136000000007733"
},
"table_name":"AlienCity",
"modified_by":{
"zuid":"66466723",
"is_confirmed":false,
"email_id":"emma@zylker.com",
"first_name":"Amelia",
"last_name":"Burrows",
"user_type":"Admin",
"user_id":"2136000000006003"
},
"modified_time":"Aug 13, 2021 01:47 PM",
"table_id":"2136000000007781"
},
"table_name":"CityDetails",
"modified_by":{
"zuid":"66466723",
"is_confirmed":false,
"email_id":"emma@zylker.com",
"first_name":"Amelia",
"last_name":"Burrows",
"user_type":"Admin",
"user_id":"2136000000006003"
},
"modified_time":"Aug 13, 2021 01:47 PM",
"table_id":"2136000000009090"
}
]
Copied[
{
"project_id":{
"project_name":"AlienCity",
"id":2136000000007733
},
"table_name":"AlienCity",
"modified_by":{
"zuid":66466723,
"is_confirmed":false,
"email_id":"emma@zylker.com",
"first_name":"Amelia",
"last_name":"Burrows",
"user_type":"Admin",
"user_id":2136000000006003
},
"modified_time":"Aug 13, 2021 01:47 PM",
"table_id":2136000000007781
},
"table_name":"CityDetails",
"modified_by":{
"zuid":66466723,
"is_confirmed":false,
"email_id":"emma@zylker.com",
"first_name":"Amelia",
"last_name":"Burrows",
"user_type":"Admin",
"user_id":2136000000006003
},
"modified_time":"Aug 13, 2021 01:47 PM",
"table_id":2136000000009090
}
]