Class: TableService

TableService

The TableService object allows you to peform management operations with the Windows Azure Table Service. The Table Service stores data in rows of key-value pairs. A table is composed of multiple rows, and each row contains key-value pairs. There is no schema, so each row in a table may store a different set of keys.

For more information on the Table Service, as well as task focused information on using it from a Node.js application, see How to Use the Table Service from Node.js.

new TableService(storageAccountOrConnectionString, storageAccessKey, host, authenticationProvider)

Creates a new TableService object. If no storageaccount or storageaccesskey are provided, the AZURE_STORAGE_ACCOUNT and AZURE_STORAGE_ACCESS_KEY environment variables will be used.

Parameters:
Name Type Argument Description
storageAccountOrConnectionString string <optional>

The storage account or the connection string.

storageAccessKey string <optional>

The storage access key.

host string <optional>

The host address.

authenticationProvider object <optional>

The authentication provider.

Source:

Extends

  • ServiceClient

Methods

createTable(table, options, callback) → {undefined}

Creates a new table within a storage account.

This:
Parameters:
Name Type Argument Description
table string

The table name.

options object <optional>

The create options.

Properties
Name Type Argument Description
timeoutIntervalInMs int <optional>

The timeout interval, in milliseconds, to use for the request.

callback function

error will contain information if an error occurs; otherwise tableResultwill contain the new table information.response` will contain information related to this operation.

Source:
Returns:
Type
undefined

createTableIfNotExists(table, options, callback) → {undefined}

Creates a new table within a storage account if it doesnt exists.

This:
Parameters:
Name Type Argument Description
table string

The table name.

options object <optional>

The create options.

Properties
Name Type Argument Description
timeoutIntervalInMs int <optional>

The timeout interval, in milliseconds, to use for the request.

callback function

error will contain information if an error occurs; otherwise created will contain the table information. response will contain information related to this operation.

Source:
Returns:
Type
undefined
Example
var azure = require('azure');
var tableService = azure.createTableService();
tableService.createTableIfNotExists('tasktable', function(error) {
  if(!error) { 
    // Table created or exists
  }
});

deleteEntity(table, entityDescriptor, options, callback) → {undefined}

Deletes an entity within a table.

This:
Parameters:
Name Type Argument Description
table string

The table name.

entityDescriptor object

The entity descriptor.

options object <optional>

The options.

Properties
Name Type Argument Description
checkEtag boolean <optional>

Boolean value indicating weather the etag should be matched or not.

timeoutIntervalInMs int <optional>

The timeout interval, in milliseconds, to use for the request.

callback function

error will contain information if an error occurs; otherwise successful will be true if the operation was successful. response will contain information related to this operation.

Source:
Returns:
Type
undefined

deleteTable(table, options, callback) → {undefined}

Deletes a table from a storage account.

This:
Parameters:
Name Type Argument Description
table string

The table name.

options object <optional>

The delete options.

Properties
Name Type Argument Description
timeoutIntervalInMs int <optional>

The timeout interval, in milliseconds, to use for the request.

callback function

error will contain information if an error occurs; otherwise successful will be true if the operation was successful. response will contain information related to this operation.

Source:
Returns:
Type
undefined

getServiceProperties(options, callback) → {undefined}

Gets the properties of a storage account’s Table service, including Windows Azure Storage Analytics.

This:
Parameters:
Name Type Argument Description
options object <optional>

The request options.

Properties
Name Type Argument Description
timeoutIntervalInMs int <optional>

The timeout interval, in milliseconds, to use for the request.

callback function

error will contain information if an error occurs; otherwise servicePropetiesResult will contain the propeties. response will contain information related to this operation.

Source:
Returns:
Type
undefined

getTable(table, options, callback) → {undefined}

Gets a table properties.

This:
Parameters:
Name Type Argument Description
table string

The table name.

options object <optional>

The get options.

Properties
Name Type Argument Description
timeoutIntervalInMs int <optional>

The timeout interval, in milliseconds, to use for the request.

callback function

error will contain information if an error occurs; otherwise tableResult will contain the table information. response will contain information related to this operation.

Source:
Returns:
Type
undefined

insertEntity(table, entityDescriptor, options, callback) → {undefined}

Inserts a new entity into a table.

This:
Parameters:
Name Type Argument Description
table string

The table name.

entityDescriptor object

The entity descriptor.

options object <optional>

The options.

Properties
Name Type Argument Description
timeoutIntervalInMs int <optional>

The timeout interval, in milliseconds, to use for the request.

callback function

error will contain information if an error occurs; otherwise entity will contain the new entity information. response will contain information related to this operation.

Source:
Returns:
Type
undefined
Example
var azure = require('azure');
var tableService = azure.createTableService();
var task1 = {
  PartitionKey : 'tasksSeattle',
  RowKey: '1',
  Description: 'Take out the trash',
  DueDate: new Date(2011, 12, 14, 12)
};
tableService.insertEntity('tasktable', task1, function(error) {
  if(!error) {
    // Entity inserted
  }
}); 

insertOrMergeEntity(table, entityDescriptor, options, callback) → {undefined}

Inserts or updates an existing entity within a table by merging new property values into the entity.

This:
Parameters:
Name Type Argument Description
table string

The table name.

entityDescriptor object

The entity descriptor.

options object <optional>

The create options or callback function.

Properties
Name Type Argument Description
timeoutIntervalInMs int <optional>

The timeout interval, in milliseconds, to use for the request.

callback function

error will contain information if an error occurs; otherwise entity will contain the entity information. response will contain information related to this operation.

Source:
Returns:
Type
undefined

insertOrReplaceEntity(table, entityDescriptor, options, callback) → {undefined}

Inserts or updates a new entity into a table.

This:
Parameters:
Name Type Argument Description
table string

The table name.

entityDescriptor object

The entity descriptor.

options object <optional>

The options.

Properties
Name Type Argument Description
timeoutIntervalInMs int <optional>

The timeout interval, in milliseconds, to use for the request.

callback function

error will contain information if an error occurs; otherwise entity will contain the entity information. response will contain information related to this operation.

Source:
Returns:
Type
undefined

mergeEntity(table, entityDescriptor, options, callback) → {undefined}

Updates an existing entity within a table by merging new property values into the entity.

This:
Parameters:
Name Type Argument Description
table string

The table name.

entityDescriptor object

The entity descriptor.

options object <optional>

The options.

Properties
Name Type Argument Description
checkEtag boolean <optional>

Boolean value indicating weather the etag should be matched or not.

timeoutIntervalInMs int <optional>

The timeout interval, in milliseconds, to use for the request.

callback function

error will contain information if an error occurs; otherwise entity will contain the entity information. response will contain information related to this operation.

Source:
Returns:
Type
undefined

queryEntities(tableQuery, options, callback) → {undefined}

Queries data in a table.

This:
Parameters:
Name Type Argument Description
tableQuery TableQuery

The query to perform.

options object <optional>

The create options.

Properties
Name Type Argument Description
timeoutIntervalInMs int <optional>

The timeout interval, in milliseconds, to use for the request.

callback function

error will contain information if an error occurs; otherwise entities will contain the entities returned by the query. If more matching entities exist, and could not be returned, queryResultContinuation will contain a continuation token that can be used to retrieve the next set of results. response will contain information related to this operation.

Source:
Returns:
Type
undefined

queryEntity(table, partitionKey, rowKey, options, callback) → {undefined}

Queries an entity in a table.

This:
Parameters:
Name Type Argument Description
table string

The table name.

partitionKey string

The partition key.

rowKey string

The row key.

options object <optional>

The options.

Properties
Name Type Argument Description
timeoutIntervalInMs int <optional>

The timeout interval, in milliseconds, to use for the request.

callback function

error will contain information if an error occurs; otherwise entity will be the matching entity. response will contain information related to this operation.

Source:
Returns:
Type
undefined
Example
var azure = require('azure');
var tableService = azure.createTableService();
tableService.queryEntity('tasktable', 'tasksSeattle', '1', function(error, serverEntity) {
  if(!error) {
    // Entity available in serverEntity variable
  }
}); 

queryTables(options, callback) → {undefined}

Enumerates the tables in a storage account.

This:
Parameters:
Name Type Argument Description
options object <optional>

The create options or callback function.

Properties
Name Type Argument Description
prefix string <optional>

Prefix of tables to query

nextTableName string <optional>

The next table name marker.

timeoutIntervalInMs int <optional>

The timeout interval, in milliseconds, to use for the request.

callback function

error will contain information if an error occurs; otherwise queryTablesResult will contain the list of tables. If more tables exist, and could not be returned, resultContinuation will contain a continuation token that can be used to retrieve the next set of results. response will contain information related to this operation.

Source:
Returns:
Type
undefined

setServiceProperties(serviceProperties, options, callback) → {undefined}

Sets the properties of a storage account’s Table service, including Windows Azure Storage Analytics. You can also use this operation to set the default request version for all incoming requests that do not have a version specified.

This:
Parameters:
Name Type Argument Description
serviceProperties object

The service properties.

options object <optional>

The request options.

Properties
Name Type Argument Description
timeoutIntervalInMs int <optional>

The timeout interval, in milliseconds, to use for the request.

callback function

error will contain information if an error occurs; otherwise response will contain information related to this operation.

Source:
Returns:
Type
undefined

updateEntity(table, entityDescriptor, options, callback) → {undefined}

Updates an existing entity within a table by replacing it.

This:
Parameters:
Name Type Argument Description
table string

The table name.

entityDescriptor object

The entity descriptor.

options object <optional>

The options.

Properties
Name Type Argument Description
checkEtag boolean <optional>

Boolean value indicating weather the etag should be matched or not.

timeoutIntervalInMs int <optional>

The timeout interval, in milliseconds, to use for the request.

callback function

error will contain information if an error occurs; otherwise entity will contain the entity information. response will contain information related to this operation.

Source:
Returns:
Type
undefined