Allow null properties for headless models
This commit is contained in:
parent
a67f75f0be
commit
eecbd32d07
|
@ -444,7 +444,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));
|
||||
};
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue