-
Notifications
You must be signed in to change notification settings - Fork 4
Table Storage
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.
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.
Creates a new table with the supplied tableName
on this storage account. Optional callback
is invoked with a reference to the newly created table as the second parameter.
Lists all tables in this storage account. Optional 'prefix' will return only those tables starting with prefix
. Passing the option {limit:n}
will return only the first n tables. Optional callback
is invoked with an array of table names as the second argument.
With no callback, an EventEmitter is immediately returned which will emit a 'data' event with each table name and an 'end' event with a total count of tables.
For example, a simple way to return a count of tables:
storage.listTables().on('end', function(err, count) {
console.log(count);
});
Because continuations are handled automatically, the above code will work for 5 containers, or 5000.
Removes the table specified by tableName
. Optional callback
is invoked with any errors.
Returns a reference to a table (the same as returned by storage.createTable
).
The createTable
and table
methods above return an instance of the Table
object. This object provides the following methods:
Inserts the key/value pairs specified in data
into the table using the supplied partition
and row
keys. Boolean, Number, String and DateTime datatypes are supported -- Number currently defaults to Edm.Double
. Optional callback is invoked with any errors.
Replaces any existing data at the supplied partition
and row
keys with the values provided in data
. Passing the option {upsert:true}
will insert the data when no row currently exists at partition
and row
.
Removes the table data at the supplied partition
and row
keys. Optional callback
is invoked with any errors.
Applies one or more equality filters to the data that will be returned from a call to rows()
. It can be used in lieu of the below methods for simple matching queries. For example:
t.filter({'city':'Atlanta', 'fruit':'peach'}).rows();
These methods are surfaced from the underlying TableQuery object provided by the Azure SDK. They can be used to construct more complicated table queries.
Applies any preceding criteria and retrieves the results. Optional callback
is invoked with an array of rows as the second argument.
With no callback, an EventEmitter is immediately returned which will emit a 'data' event with each row and an 'end' event with a total count of rows.
Once rows()
has been invoked, all preceding search criteria (filter(), select(), etc.) is reset.
Returns the underlying BlobService object from the Azure SDK.