Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
delete items in Amazon SimpleDB (require node.js and aws-javascript-sdk)
var config = require('../config.json');
var AWS = require('aws-sdk');
AWS.config.loadFromPath('config.json');
var simpledb = new AWS.SimpleDB();
var delete_item = function (name, data) {
var params = {
DomainName: config.domainName,
Items: [
{
Name: name,
Attributes: data.Attributes
}
]
};
simpledb.batchDeleteAttributes(params, function (err, data) {
if (err) {
console.log(err);
} else {
console.log('delete: ' + name);
}
});
};
var get_delete_item = function (name) {
var params = {
DomainName: config.domainName,
ItemName: name
};
simpledb.getAttributes(params, function (err, data) {
if (err) {
console.log(err);
} else {
delete_item(name, data);
}
});
};
var search_delete_items = function (sql, next_token) {
var params = {
SelectExpression: sql,
NextToken: next_token
};
simpledb.select(params, function (err, data) {
if (err) {
console.log(err);
} else {
data.Items.forEach(function (item) {
get_delete_item(item.Name);
});
if (data.NextToken) {
search_items(sql, data.NextToken)
}
}
});
};
search_delete_items("select * from `" + config.domainName + "` where Level = 'INFO'", null);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment