Created
July 20, 2012 18:08
-
-
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.
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
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