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

Table Storage

Tuskan360 edited this page Apr 8, 2012 · 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
    }
});
Clone this wiki locally