Skip to content

Instantly share code, notes, and snippets.

@wvl
Last active December 16, 2015 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wvl/5390904 to your computer and use it in GitHub Desktop.
Save wvl/5390904 to your computer and use it in GitHub Desktop.
var fa = require('fa');
function clear_db(client) {
console.log("In clear_db");
client.hkeys("tug", function(err, replies) {
if (err) {
return console.error("error response - " + err);
}
console.log(replies.length + " replies:");
fa.with_index().each(replies, function(name, i, cb) {
console.log(" " + i + ": " + name);
client.hget("tug", name, function(err, val) {
console.log("key " + name + " is " + val);
cb();
});
}, function(err) {
console.log('Done');
client.quit();
});
});
}
function clear_db(client) {
console.log("In clear_db");
client.hkeys("tug", function(err, replies) {
if (err) {
return console.error("error response - " + err);
}
console.log(replies.length + " replies:");
replies.forEach(function(name, i) {
console.log(" " + i + ": " + name);
client.hget("tug", name, function(err, val) {
console.log("key " + name + " is " + val);
});
});
});
}
function clear_db(client, callback) {
client.hgetall('tug', function(err, obj) {
console.log("Result: ", obj);
client.quit();
callback();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment