Skip to content
This repository has been archived by the owner on Nov 9, 2024. It is now read-only.

Table Storage

pofallon edited this page Jan 17, 2012 · 19 revisions

The table storage API functionality can be put into two groups: (1) methods provided with 'storage' that allow manipulation of the tables themselves and (2) methods on the 'table' object used to manipulate table attributes and data.

1. Table-related 'storage' methods

These methods are accessible via the storage object. In reality, the functionality is found in static methods of the Table object -- these proxy methods are provided for convenience.

storage.createTable(tableName, callback)

Creates a new table with the supplied tableName on this storage account. callback is passed a reference to the newly created table.

storage.listTables(callback)

Lists all tables in this storage account. Invokes callback with an array of table names.

storage.removeTable(tableName, callback)

Removes the table specified by tableName.

storage.table(tableName)

Returns a reference to a table (the same as returned by storage.createTable).

2. Table instance methods

The createTable and table methods above return an instance of the Table object. This object provides the following methods:

table.insert(partition, row, data, callback)

Inserts the key/value pairs specified in data into the table using the supplied partition and row keys. Boolean, Number, String and DateTime datatypes supported -- Number currently defaults to Edm.Double.

table.update(partition, row, data, options?, callback)

Replaces any existing data at the supplied partition and row keys with the values provided in data. Available options include:

  • upsert - When true, and no row currently exists at partition and row, the data will be inserted. Defaults to false.

table.del(partition, row, callback)

Removes the table data at the supplied partition and row keys.

table.fields(fieldArray)

Defines a subset of fields to be returned from a query, specified in fieldArray. Can be useful for performance and bandwidth optimization.

table.filter(criteria)

Applies a filter to the rows that will be returned from a query.

table.all(callback)

Applies any fields or filters and invokes callback with an array of the results.

table.forEach(callback, doneCallback)

Applies any fields or filters and invokes callback for each row in the results and (optionally) doneCallback with the count of rows when done. (Errors are sent to callback, or doneCallback if provided. Both callback and doneCallback expect 'err' as their first parameter.)

A Note about 'table' methods

filter and field are meant to be chained with all or forEach in a fluent API style, for example:

table.fields(['firstName','lastName']).filter({'state':'CA'}).forEach(callback, doneCallback);
Clone this wiki locally