Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Código de ejemplo para el TechDay Bogotá 2014. Muestra cómo usar NodeJS sobre Azure Mobile Services, para proveer un API que permite actuar sobre las tablas del Azure Storage
/**
* Created by War on 6/11/2014.
*/
var azure = require('azure');
exports.post = function (request, response) {
var tableService = azure.createTableService("ACCOUNTNAME", "PAK");
//Setting working variables from post parameters
var cleankName = request.body.cleankName;
var url = request.body.url;
var tags = request.body.tags;
var task = {
PartitionKey: 'warnov', RowKey: cleankName, Tags: tags, Url: url
};
tableService.insertEntity('Cleanks', task, function (error) {
if (!error) {
var tagArray = tags.split(",");
tagArray.forEach(function (tag) {
tableService.queryEntity('Tags'
, 'warnov'
, tag
, function (error, entity) {
if (error) {//this is a new tag
var task = {
PartitionKey: 'warnov', RowKey: tag, Cleanks: cleankName
};
tableService.insertEntity('Tags', task, finish_);
} else update(entity);
}
)
});
} else {
response.send(500, { message: "Unable to insert cleank" });
}
});
function update(entity) {
var currentCleanks = entity.Cleanks;
entity.Cleanks = currentCleanks + "," + cleankName;
tableService.insertOrMergeEntity(
'Tags'
, entity
, finish_
);
}
function finish_(error) {
if (!error)response.send(200, {message: "Tag successfully inserted"});
else response.send(500, {message: "Unable to insert tag"});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.