Skip to content

Instantly share code, notes, and snippets.

@safwank
Created August 5, 2012 07:07
Show Gist options
  • Save safwank/3262543 to your computer and use it in GitHub Desktop.
Save safwank/3262543 to your computer and use it in GitHub Desktop.
Sample code on how to use Redis to keep track of the total number of nodes exported to Neo4J
Business.loadFromCSV = function(csvFilePath) {
csv().fromPath(csvFilePath, { columns: true, trim: true })
.on('data', loadBusiness)
.on('end', handleSuccess)
.on('error', handleLoadError);
};
function loadBusiness(data, index) {
var business = data;
util.removeNullOrEmptyPropertiesIn(business);
Business.create(business, handleCreated);
}
function handleSuccess(count) {
console.log('Number of businesses created: ' + count);
redisUtil.incrementTotalNodesBy(count);
}
function handleCreated(error, data) {
if (error) console.log(error.message);
console.log('Created: ' + data);
redisUtil.decrementTotalNodes();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment