Use matches in .where

This commit is contained in:
Graeme Yeates
2014-10-03 00:21:05 -04:00
committed by Adam Krebs
parent 5025d3ce71
commit b93030b0d8

View File

@@ -833,12 +833,9 @@
// Return models with matching attributes. Useful for simple cases of
// `filter`.
where: function(attrs, first) {
if (_.isEmpty(attrs)) return first ? void 0 : [];
var matches = _.matches(attrs);
return this[first ? 'find' : 'filter'](function(model) {
for (var key in attrs) {
if (attrs[key] !== model.get(key)) return false;
}
return true;
return matches(model.attributes);
});
},