I chose to override where and findWhere on my collections to allow for a caseInsensitive option:
//case-insensitive where
where: function(attrs, first, options){
options = options || {};
if (_.isEmpty(attrs)) return first ? void 0 : [];
return this[first ? 'find' : 'filter'](function(model) {
for (var key in attrs) {
if (options.caseInsensitive) {
if (attrs[key].toLowerCase() !== model.get(key).toLowerCase()) return false;
} else {
if (attrs[key] !== model.get(key)) return false;
}
}
return true;
});
},
findWhere: function(attrs, options) {
return this.where(attrs, true, options);
}
And call it by:
collection.findWhere({username: "AwEsOmE"}, {caseInsensitive: true});
Its not exactly pretty, but neither is the original implementation. O_o
It would also be great to open this as a pull request, but refactor the 'first' variable in the where function to be key in options. It's on my list of things to do.