nedb
Advanced tools
Comparing version 1.1.4 to 1.2.0
@@ -412,8 +412,9 @@ /** | ||
try { | ||
keys = Object.keys(updateQuery[m]); | ||
} catch (e) { | ||
// Can't rely on Object.keys throwing on non objects since ES6{ | ||
// Not 100% satisfying as non objects can be interpreted as objects but no false negatives so we can live with it | ||
if (typeof updateQuery[m] !== 'object') { | ||
throw "Modifier " + m + "'s argument must be an object"; | ||
} | ||
keys = Object.keys(updateQuery[m]); | ||
keys.forEach(function (k) { | ||
@@ -420,0 +421,0 @@ modifierFunctions[m](newDoc, k, updateQuery[m][k]); |
{ | ||
"name": "nedb", | ||
"version": "1.1.4", | ||
"version": "1.2.0", | ||
"author": { | ||
@@ -24,8 +24,8 @@ "name": "Louis Chatriot", | ||
"async": "0.2.10", | ||
"underscore": "~1.4.4", | ||
"binary-search-tree": "0.2.4", | ||
"mkdirp": "~0.5.1" | ||
"mkdirp": "~0.5.1", | ||
"underscore": "~1.4.4" | ||
}, | ||
"devDependencies": { | ||
"chai": "1.0.x", | ||
"chai": "^3.2.0", | ||
"mocha": "1.4.x", | ||
@@ -32,0 +32,0 @@ "request": "2.9.x", |
var model = require('../lib/model') | ||
, should = require('chai').should() | ||
, assert = require('chai').assert | ||
, expect = require('chai').expect | ||
, _ = require('underscore') | ||
@@ -312,5 +313,5 @@ , async = require('async') | ||
(function () { | ||
expect(function () { | ||
model.modify(obj, updateQuery); | ||
}).should.throw(); | ||
}).to.throw("You cannot change a document's _id"); | ||
@@ -325,5 +326,5 @@ updateQuery._id = 'keepit'; | ||
(function () { | ||
expect(function () { | ||
model.modify(obj, updateQuery); | ||
}).should.throw(); | ||
}).to.throw("You cannot mix modifiers and normal fields"); | ||
}); | ||
@@ -333,7 +334,7 @@ | ||
var obj = { some: 'thing' } | ||
, updateQuery = { $set: 'this exists', $modify: 'not this one' }; | ||
, updateQuery = { $set: { it: 'exists' }, $modify: 'not this one' }; | ||
(function () { | ||
expect(function () { | ||
model.modify(obj, updateQuery); | ||
}).should.throw(); | ||
}).to.throw(/^Unknown modifier .modify/); | ||
}); | ||
@@ -345,5 +346,5 @@ | ||
(function () { | ||
expect(function () { | ||
model.modify(obj, updateQuery); | ||
}).should.throw(); | ||
}).to.throw(/Modifier .set's argument must be an object/); | ||
}); | ||
@@ -350,0 +351,0 @@ |
782936
18116