added 'all' method to hasMany in abstract-class.js to correctly support a 'many' collection. added .idea to .gitignore to ignore WebStorm projects.
This commit is contained in:
parent
fb8d0acc80
commit
6f9c495720
|
@ -3,5 +3,6 @@ doc
|
||||||
coverage.html
|
coverage.html
|
||||||
coverage
|
coverage
|
||||||
v8.log
|
v8.log
|
||||||
|
.idea**
|
||||||
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
|
@ -839,6 +839,7 @@ AbstractClass.hasMany = function hasMany(anotherClass, params) {
|
||||||
return {where: x};
|
return {where: x};
|
||||||
}, {
|
}, {
|
||||||
find: find,
|
find: find,
|
||||||
|
all: all,
|
||||||
destroy: destroy
|
destroy: destroy
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -857,6 +858,23 @@ AbstractClass.hasMany = function hasMany(anotherClass, params) {
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function all(filter,cb) {
|
||||||
|
if (!filter) {
|
||||||
|
filter = {};
|
||||||
|
}
|
||||||
|
if (!filter.where) {
|
||||||
|
filter.where = {};
|
||||||
|
}
|
||||||
|
filter.where[fk] = this.id.toString();
|
||||||
|
|
||||||
|
anotherClass.all(filter,function(err,inst){
|
||||||
|
if (err) return cb(err);
|
||||||
|
if (!inst) return cb(null,[]);
|
||||||
|
else return cb(null,inst);
|
||||||
|
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
function destroy(id, cb) {
|
function destroy(id, cb) {
|
||||||
this.find(id, function (err, inst) {
|
this.find(id, function (err, inst) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
|
|
Loading…
Reference in New Issue