Get Table Metadata

The metadata of a single table in the Catalyst Data Store can be obtained in two ways. The datastore reference used in the code snippets below is the component instance.

Get a Table’s Metadata by Table ID

A table’s meta data is fetched by referring the table Id, using the method getTableDetails() as given below,

    
copy
//Get a Single Table's details using table ID let datastore = app.datastore(); let tablePromise = datastore.getTableDetails(1510000000110121); tablePromise.then((table) => { console.log(table); });

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

    
Node JS
copy
{
"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"
}
{
"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 a Table’s Metadata by Table Name

When the table’s metadata is to be fetched by referring the table name, the below code snippet can be used. However, note that when the table name is changed in the future, it must be reflected in all the places wherever it is used in the code.

In both cases, a promise is returned, which in turn resolves to the table meta details. The resultant meta can be converted to a string or JSON output by accessing .toString() or .toJSON() methods.

    
copy
//Get a Single Table's details using the table name let datastore = app.datastore(); let tablePromise = datastore.getTableDetails('SampleTable'); tablePromise.then((table) => { console.log(table); });

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

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

{ “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

In addition to getting the meta data of a single table, you can fetch the details of all the tables in a catalyst project using getAllTables() method.

The promise returned here will be resolved to an array of table meta details.

    
copy
//Get meta data of all tables let datastore = app.datastore(); let allTablePromise = datastore.getAllTables(); allTablePromise.then((tables) => { console.log(tables); });

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

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

Last Updated 2023-09-03 01:06:41 +0530 +0530