Skip to content

Commit

Permalink
allow unsetting document arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
aheckmann committed Feb 24, 2012
1 parent f3f3028 commit b30e128
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/schema/documentarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ DocumentArray.prototype.doValidate = function (array, fn, scope) {
SchemaType.prototype.doValidate.call(this, array, function(err){
if (err) return fn(err);

var count = array.length
var count = array && array.length
, error = false;

if (!count) return fn();
Expand Down
2 changes: 2 additions & 0 deletions test/model.querying.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1286,12 +1286,14 @@ module.exports = {
b.comments[1].body.should.equal('cranberries');

b.meta = undefined;
b.comments = undefined;
b.save(function (err) {
should.strictEqual(null, err);
B.collection.findOne({ _id: b._id}, function (err, b) {
db.close();
should.strictEqual(null, err);
should.strictEqual(undefined, b.meta);
should.strictEqual(undefined, b.comments);
});
});
});
Expand Down

0 comments on commit b30e128

Please sign in to comment.