Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow null properties for headless models

  • Loading branch information...
commit 8936278e73e22044ecd73902763b5218d075c975 1 parent 6ad4886
@1602 authored
Showing with 8 additions and 4 deletions.
  1. +3 −1 lib/model.js
  2. +1 −0  lib/schema.js
  3. +4 −3 test/relations.test.js
View
4 lib/model.js
@@ -445,7 +445,9 @@ AbstractClass.destroyAll = function destroyAll(cb) {
if (stillConnecting(this.schema, this, arguments)) return;
this.schema.adapter.destroyAll(this.modelName, function (err) {
- cb(err);
+ if ('function' === typeof cb) {
+ cb(err);
+ }
}.bind(this));
};
View
1  lib/schema.js
@@ -176,6 +176,7 @@ Schema.prototype.define = function defineClass(className, properties, settings)
if (args.length == 1) properties = {}, args.push(properties);
if (args.length == 2) settings = {}, args.push(settings);
+ properties = properties || {};
settings = settings || {};
// every class can receive hash of data as optional param
View
7 test/relations.test.js
@@ -183,8 +183,8 @@ describe('relations', function() {
t.should.be.an.instanceOf(Tag);
ArticleTag.findOne(function(e, at) {
should.exist(at);
- at.tagId.should.equal(t.id);
- at.articleId.should.equal(article.id);
+ at.tagId.toString().should.equal(t.id.toString());
+ at.articleId.toString().should.equal(article.id.toString());
done();
});
});
@@ -220,7 +220,8 @@ describe('relations', function() {
Article.findOne(function(e, article) {
article.tags(function(e, tags) {
var len = tags.length;
- article.tags.remove(tags[0], function(e, at) {
+ tags.should.not.be.empty;
+ article.tags.remove(tags[0], function(e) {
should.not.exist(e);
article.tags(true, function(e, tags) {
tags.should.have.lengthOf(len - 1);
Please sign in to comment.
Something went wrong with that request. Please try again.