Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Why are models without IDs added to the store? #411
Is there was any particular reason that Backbone-Relational models without IDs are added to the store? The reason I ask is that I'm thinking of submitting a pull request where they only get added if/when they get an ID, but thought I'd check if there was any obvious reason that it wouldn't work.
Our use-case is that, in addition to using Backbone.Relational for managing regular related data, I'm also using it for deserializing and serializing 'view-models' that don't actually have IDs. At the moment these related view models go into the store, even though they're only used on a one-off basis. I don't need to ensure object uniqueness for them, and I don't want them to hang around in memory.
On another project where we weren't using Backbone-Relational, we wrote an identity map where a model only got added once it got an ID (see https://github.com/shinetech/backbone-identity-map/blob/master/backbone-identity-map.js). I'd be happy to write a pull request to bring this sort of behaviour into Backbone-Relational.
I don't think there's a particular reason they need to be in the store. However, up until now, we've just been using the simplest possible solution of putting every model in on creation.
We already do checking for id changes in