Skip to content

Commit

Permalink
ignore fields not in model while saving and don't make an error.
Browse files Browse the repository at this point in the history
  • Loading branch information
shimondoodkin committed Nov 18, 2015
1 parent 7d01fab commit 3e3c9d9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/modelinstance.js
Expand Up @@ -263,8 +263,11 @@ ModelInstance.prototype._toJSON = function(refType, forceTyping) {
/* istanbul ignore else */
if (this.hasOwnProperty(i)) {
var field = $.schema.field(i);
objOut[i] =
_encodeValue($.schema.context, field.type, this[i], forceTyping);
if(field)
objOut[i] =
_encodeValue($.schema.context, field.type, this[i], forceTyping);
else
console.log('field is null', i, '=', this[i], 'not saved to db. to not see this, run: \'delete obj.'+i+'\' before saving');
}
}
return objOut;
Expand Down

0 comments on commit 3e3c9d9

Please sign in to comment.