Last active
December 15, 2015 13:18
-
-
Save ChrisRisner/5266066 to your computer and use it in GitHub Desktop.
TableStorage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var azure = require('azure'); | |
function del(id, user, request) { | |
var accountName = 'accountname'; | |
var accountKey = 'accountkey'; | |
var host = accountName + '.table.core.windows.net'; | |
var tableService = azure.createTableService(accountName, accountKey, host); | |
tableService.deleteEntity(request.parameters.tableName, | |
{ | |
PartitionKey : request.parameters.partitionKey | |
, RowKey : request.parameters.rowKey | |
} | |
, function (error) { | |
if (!error) { | |
request.respond(200); | |
} else { | |
request.respond(500); | |
} | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var azure = require('azure'); | |
function insert(item, user, request) { | |
var accountName = 'accountname'; | |
var accountKey = 'accountkey'; | |
var host = accountName + '.table.core.windows.net'; | |
var tableService = azure.createTableService(accountName, accountKey, host); | |
tableService.insertEntity(request.parameters.table, item, function (error) { | |
if (!error) { | |
request.respond(200, item); | |
} else { | |
request.respond(500); | |
} | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var azure = require('azure'); | |
function read(query, user, request) { | |
var accountName = 'accountname'; | |
var accountKey = 'accountkey'; | |
var host = accountName + '.table.core.windows.net'; | |
var tableService = azure.createTableService(accountName, accountKey, host); | |
var tq = azure.TableQuery | |
.select() | |
.from(request.parameters.table); | |
tableService.queryEntities(tq, function (error, rows) { | |
if (error) { | |
request.respond(500, error); | |
} else { | |
request.respond(200, rows) | |
} | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var azure = require('azure'); | |
function update(item, user, request) { | |
var accountName = 'accountname'; | |
var accountKey = 'accountkey'; | |
var host = accountName + '.table.core.windows.net'; | |
var tableService = azure.createTableService(accountName, accountKey, host); | |
tableService.updateEntity(request.parameters.table, item, function (error) { | |
if (!error) { | |
request.respond(200, item); | |
} else { | |
request.respond(500); | |
} | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var azure = require('azure'); | |
function del(id, user, request) { | |
var accountName = 'accountname'; | |
var accountKey = 'accountkey'; | |
var host = accountName + '.table.core.windows.net'; | |
var tableService = azure.createTableService(accountName, accountKey, host); | |
tableService.deleteTable(request.parameters.tableName, function (error) { | |
if (!error) { | |
request.respond(200); | |
} else { | |
request.respond(500); | |
} | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var azure = require('azure'); | |
function insert(item, user, request) { | |
var accountName = 'accountname'; | |
var accountKey = 'accountkey'; | |
var host = accountName + '.table.core.windows.net'; | |
var tableService = azure.createTableService(accountName, accountKey, host); | |
tableService.createTable(item.tableName, function (error) { | |
if (!error) { | |
request.respond(200, item); | |
} else { | |
request.respond(500); | |
} | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var azure = require('azure'); | |
function read(query, user, request) { | |
var accountName = 'accountname'; | |
var accountKey = 'accountkey'; | |
var host = accountName + '.table.core.windows.net'; | |
var tableService = azure.createTableService(accountName, accountKey, host); | |
tableService.queryTables(function (error, tables) { | |
if (error) { | |
request.respond(500, error); | |
} else { | |
request.respond(200, tables); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment