Permalink
Browse files

Simplify `get` method for “undefined” id case

  • Loading branch information...
dhritzkiv committed Dec 18, 2017
1 parent 3b6cfb6 commit fed13d182b77da0daba4f2536118e08b1c99c429
Showing with 16 additions and 3 deletions.
  1. +16 −3 ampersand-collection.js
View
@@ -166,9 +166,22 @@ assign(Collection.prototype, AmpersandEvents, {
get: function (query, indexName) {
if (query == null) return;
var index = this._indexes[indexName || this.mainIndex];
if(index && index[query[this.mainIndex]] && query[this.mainIndex] === undefined) return;
return (index && (index[query] || index[query[this.mainIndex]])) || this._indexes.cid[query] || this._indexes.cid[query.cid];
var collectionMainIndex = this.mainIndex;
var index = this._indexes[indexName || collectionMainIndex];
return (
(
index && (
index[query] || (
query[collectionMainIndex] !== undefined &&
index[query[collectionMainIndex]]
)
)
) ||
this._indexes.cid[query] ||
this._indexes.cid[query.cid]
);
},
// Get the model at the given index.

0 comments on commit fed13d1

Please sign in to comment.