Skip to content

Instantly share code, notes, and snippets.

@jameshartig
Created March 9, 2015 22:26
Show Gist options
  • Save jameshartig/67161afe7616ffa8632a to your computer and use it in GitHub Desktop.
Save jameshartig/67161afe7616ffa8632a to your computer and use it in GitHub Desktop.
// If a duplicate is found, prevent it from being added and
// optionally merge it into the existing model.
existing = this.get(attrs);
if (!existing) {
model = newModels[i] = this._prepareModel(attrs, options);
if (!model) continue;
existing = this.get(model);
}
if (existing) {
....
} else if (add) {
toAdd.push(model);
this._addReference(model, options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment