Enyo different collection with same model kind

edited April 2014 in Enyo 2.4
I have been trying to create two collection with a common model kind. I am getting the following error:

"Uncaught enyo.Store.addRecord: duplicate record added to store for kind app.ImageModel with primaryKey set to id and the same value of 67774271 which cannot coexist for the kind without the ignoreDuplicates flag of the store set to true ".

Following are the two collection i have defined...

enyo.kind({
name: "app.FeatureCollection",
kind: "enyo.Collection",
model: "app.ImageModel",
defaultSource: "appF",
...
...
});


enyo.kind({
name: "app.SearchCollection",
kind: "enyo.Collection",
model: "app.ImageModel",
defaultSource: "appS",
...
...
});
And the model which i am using is as follows:

enyo.kind({
name: "app.ImageModel",
kind: "enyo.Model",
readOnly: true,
....
....
});
At one point i am setting like this:

this.set("data", new app.FeatureCollection());

and in another,

this.set("data", new app.SearchCollection());


Setting "ignoreDuplicates" to true on "enyo.Store", but someone clarify why this situation is coming? If the data received have some common data as fetched previously, this error comes. For one collection and a model, this doesn't appear,even though some data is same as previous, but as i go for two separate collection with a common model, the error comes somehow!

Comments

  • enyo.Store maintains a local copy of every Model mapped by the primaryKey and the euid. The primaryKey is pulled from the Model and is "id" be default. The euid is generated by the framework at runtime to uniquely identify Model instances. When you create a model (either directly via new enyo.Model() or indirectly by passing an object to enyo.Collection.add/merge), a reference to the model is added to enyo.Store's map. If an Model exists with the same primaryKey value and a different euid, you get this error to inform you that you have 2 Model instances representing the same entity.
Sign In or Register to comment.