Created
August 5, 2012 07:07
-
-
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
This file contains 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
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