Skip to content

Commit

Permalink
feat(Document): refactor to use vanilla js instead of lodash for empt…
Browse files Browse the repository at this point in the history
…y checks
  • Loading branch information
missinglink committed Jul 7, 2017
1 parent 682c81d commit 059e453
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,15 @@ Document.prototype.toESDocument = function() {
};

// remove empty properties
if( _.isEmpty( doc.parent ) ){ delete doc.parent; }
if( _.isEmpty( doc.address_parts ) ){ delete doc.address_parts; }
if( _.isEmpty( this.category ) ){ delete doc.category; }
if( !Object.keys( doc.parent || {} ).length ){
delete doc.parent;
}
if( !Object.keys( doc.address_parts || {} ).length ){
delete doc.address_parts;
}
if( !( this.category || [] ).length ){
delete doc.category;
}

return {
_index: config.schema.indexName,
Expand Down

0 comments on commit 059e453

Please sign in to comment.