Search code examples
javascriptazureazure-storageazure-table-storage

Fetch specific columns from Azure storage table query with the Javascript API


Is it possible to fetch specific columns from an Azure storage table with the Javascript library.

Right now I can fetch the entire row, but I want just a few of the columns.

Here is what I'm doing to fetch the entire row from the table

var tableUri = "https://mytablerg.table.core.windows.net";
var tableService = AzureStorage.Table.createTableServiceWithSas(tableUri, sasToken);
var tableQuery = new AzureStorage.Table.TableQuery().top(100).where('PartitionKey eq ?', partitionName);

tableService.queryEntities('ChatMessages', tableQuery, null, function(error, result, response) {
   // do some work with a returned data
});


Solution

  • Appending your original query with method select() should work.

    var tableQuery = new AzureStorage.Table.TableQuery().top(100).where('PartitionKey eq ?', partitionName).select('field1','field2');
    

    Have a look at the official doc.