id duplication nightmare
Hi all! I am searching on server with backbone collection (with related models), so every time someone search I do a:
collection.fecth();
The problem is that i cant search twice something beacuse I am getting a duplicte Id. It is already on store but it is the same object, is there a way to avoid that.
Maybe If the object on collection is the same on the store dont throw duplicate id exception.
I know that already exist findOrCreate() but i cant use it (on collections).
I think Relational needs to have something at collection level doing the same thing.
Generally a collection.fetch() won't throw that error because it will automatically reuse any model instances that exist with the same ID.
I experienced some edge cases (described in #342) where a race condition can cause this error if you're POSTing a new model and fetching the collection right around the same time. Is that what you're doing?
I am using Backbone.io that sync models/collections over socket.io instead of using ajax.
It might be something with that I need to research more.