Closed hendiko closed 7 years ago
If some one coincidentally calls create() method with models that have some id, it would continuously add the id into records. I think it might be a potential problem when some model with a long id.
Example:
> foo = new Store('foo') > B…e.L…e.w…w.Store {name: "foo", records: Array[0]} > foo.records > [] > foo.create({id: 1}) > Object {id: 1} > foo.create({id: 1}) > Object {id: 1} > foo.records > ["1", "1"]
I added a line in create method to prevent from adding duplicate ids into records.
this.records.indexOf(model.id.toString()) < 0 && this.records.push(model.id.toString());
Good spot on this @hendiko. The localStorage adapter should map onto Collection's expected functionality of maintaining ID uniqueness.
If some one coincidentally calls create() method with models that have some id, it would continuously add the id into records. I think it might be a potential problem when some model with a long id.
Example:
I added a line in create method to prevent from adding duplicate ids into records.