Skip to content

Instantly share code, notes, and snippets.

@safwank
Created July 20, 2012 18:08
Show Gist options
  • Save safwank/3152328 to your computer and use it in GitHub Desktop.
Save safwank/3152328 to your computer and use it in GitHub Desktop.
Sample code on how to remove null or empty properties before creating a node in Neo4J.
function isNullOrEmpty(value) {
return !value || value.length === 0 || /^\s*$/.test(value);
}
function removeNullOrEmptyPropertiesIn(object) {
for (var propertyName in object)
{
var propertyValue = object[propertyName];
if (isNullOrEmpty(propertyValue))
delete object[propertyName];
}
}
function loadBusiness(data, index) {
var business = data;
removeNullOrEmptyPropertiesIn(business);
Business.create(business, handleCreated);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment