Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Table Storage

jeffwilcox edited this page Feb 15, 2013 · 8 revisions

To ensure a table exists, call createTableIfNotExists:

var tableService = azure.createTableService();
tableService.createTableIfNotExists('tasktable', function(error){
    if(!error){
        // Table exists
    }
});

A new entity can be added by calling insertEntity:

var tableService = azure.createTableService(),
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
    }
});

The method queryEntity can then be used to fetch the entity that was just inserted:

var tableService = azure.createTableService();
tableService.queryEntity('tasktable', 'tasksSeattle', '1', function(error, serverEntity){
    if(!error){
        // Entity available in serverEntity variable
    }
});

Methods

getServiceProperties([options], callback)

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

[options]
(object) The request options
[options.timeoutIntervalInMs]
(int) The timeout interval, in milliseconds, to use for the request.
callback
(function(error, servicePropertiesResult, response)) The callback function

setServiceProperties(serviceProperties, [options], callback)

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.

serviceProperties
(object) The service properties
[options]
(object) The request options
[options.timeoutIntervalInMs]
(int) The timeout interval, in milliseconds, to use for the request.
callback
(function(error, response)) The callback function

getTable(table, [options], callback)

Gets a table properties.

table
(string) The table name
[options]
(object) The request options
[options.timeoutIntervalInMs]
(int) The timeout interval, in milliseconds, to use for the request.
callback
(function(error, tableResult, response)) The callback function

createTable(table, [options], callback)

Creates a new table within a storage account.

Create a table with the given table name. This will return an error if the table already exists.

table
(string) The table name
[options]
(object) The request options
[options.timeoutIntervalInMs]
(int) The timeout interval, in milliseconds, to use for the request.
callback
(function(error, tableResult, response)) The callback function

createTableIfNotExists(table, [options], callback)

Creates a new table within a storage account if it doesn't exist.

table
(string) The table name
[options]
(object) The request options
[options.timeoutIntervalInMs]
(int) The timeout interval, in milliseconds, to use for the request.
callback
(function(error, created, response)) The callback function

deleteTable(table, [options], callback)

Deletes a table from a storage account.

table
(string) The table name
[options]
(object) The request options
[options.timeoutIntervalInMs]
(int) The timeout interval, in milliseconds, to use for the request.
callback
(function(error, successful, response)) The callback function

queryTables([options], callback)

Enumerates the tables in a storage account.

[options]
(object) The request options
[options.nextTableName]
(string) The next table name marker.
[options.timeoutIntervalInMs]
(int) The timeout interval, in milliseconds, to use for the request.
callback
(function(error, queryTablesResult, response)) The callback function

queryEntity(table, partitionKey, rowKey, [options], callback)

Queries an entity in a table.

table
(string) The table name
partitionKey
(string) The partition key
rowKey
(string) The row key
[options]
(object) The request options
[options.timeoutIntervalInMs]
(int) The timeout interval, in milliseconds, to use for the request.
callback
(function(error, tableEntity, response)) The callback function

queryEntities(tableQuery, [options], callback)

tableQuery
(TableQuery) The query to perform
[options]
(object) The request options
[options.timeoutIntervalInMs]
(int) The timeout interval, in milliseconds, to use for the request.
callback
(function(error, queryEntitiesResult, queryEntitiesContinuation, response)) The callback function