I have been using backbone relational (https://github.com/PaulUithol/Backbone-relational) to build my application because I have a model (Room) with lots of other models attached:
As you can see in this issue I keep getting the error
Error: Cannot instantiate more than one Backbone.RelationalModel with the same id per type
Whenever I change View or reload a Collection.
Now I know there is a thread here where they suggest using findOrCreate
but I am not accessing models individually, but am instead using Collection.fetch
. Is there a way around this problem?
with backbone-relational you can get or create object from relational store. Use this to create relational objects:
this.model = someModel.findOrCreate({id: 123})
With this it will create new object or get existing one from relational store.
http://backbonerelational.org/#RelationalModel-findOrCreate
I had a similar problem, fixed it by switching to Backbone-associations.
https://github.com/dhruvaray/backbone-associations
The interface is almost exactly the same with only a few minor differences so porting should be pretty simple.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With