diff --git a/lib/model.js b/lib/model.js index 29b4161..22896bd 100644 --- a/lib/model.js +++ b/lib/model.js @@ -44,7 +44,7 @@ function checkObject (obj) { }); } - if (typeof obj === 'object') { + if (typeof obj === 'object' && obj !== null) { Object.keys(obj).forEach(function (k) { checkKey(k, obj[k]); checkObject(obj[k]); diff --git a/package.json b/package.json index 4f088dc..b826b5f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nedb", - "version": "0.7.3", + "version": "0.7.4", "author": { "name": "tldr.io", "email": "hello@tldr.io" diff --git a/test/model.test.js b/test/model.test.js index e1d243b..30903f4 100644 --- a/test/model.test.js +++ b/test/model.test.js @@ -159,6 +159,12 @@ describe('Model', function () { // Recursive behaviour testing done in the above test on $ signs }); + it('Properties with a null value dont trigger an error', function () { + var obj = { prop: null }; + + model.checkObject(obj); + }); + }); // ==== End of 'Object checking' ==== //