dStore question

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

dStore question

Rob Gillan-2
Hi all,

About to try out 1.11 but before we do we are cutting over to dStore for our dGrids.  We are having some problems with data not being stored correctly.  We are using Trackable and Memory stores, with an idProperty of ‘_id’ (we are feeding it from Mongo so it makes things easy, this was how we did it with dojo/store as well).  It’s a very simple memory store to start.

We have tried both put and putSync with the same result.

We start with an array of data with two entries.

am.applets: [{"_id":"56cbb096f3d117dc439bdb9e","@attributes":{"name":"am","title":"am","version":"100","id":"am","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}},{"_id":"56cbb0c2f3d117dc439bdb9f","@attributes":{"name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}}]


We cycle through the array and put each entry into the store (with overwrite):

        am.appletStore = new TrackableMemoryStore({idProperty: '_id'});

        for (i = 0; i < am.applets.length; i++) {
                am.appletStore.put(am.applets[i], {overwrite: true});
        }

When we inspect the store it shows the second entry appearing twice, rather than the two unique rows:

am.appletStore:{"idProperty":"_id","storage":{"version":4,"fullData":[{"_id":"56cbb0c2f3d117dc439bdb9f","name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"},{"_id":"56cbb0c2f3d117dc439bdb9f","name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}],"index":{"56cbb096f3d117dc439bdb9e":0,"56cbb0c2f3d117dc439bdb9f":1}},"_inherited":{"p":2},"data":[{"_id":"56cbb0c2f3d117dc439bdb9f","name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"},{"_id":"56cbb0c2f3d117dc439bdb9f","name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}]}

If we then receive an updated array of data and try and update the store:

am.applets:[{"_id":"56cbb096f3d117dc439bdb9e","@attributes":{"name":"am","title":"am","version":"100","id":"am","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}},{"_id":"56cbb0c2f3d117dc439bdb9f","@attributes":{"name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}},{"_id":"56cbb2e6f3d117dc439bdba0","@attributes":{"name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}}]

we would have expected running through the same update (put) loop it would have then had three unique rows in the store, but alas it has seemed to triplicate the last entry across all three positions (and obviously the grid shows that as well.

am.appletStore:{"idProperty":"_id","storage":{"version":7,"fullData":[{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"},{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"},{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}],"index":{"56cbb096f3d117dc439bdb9e":0,"56cbb0c2f3d117dc439bdb9f":1,"56cbb2e6f3d117dc439bdba0":2}},"_inherited":{"p":2},"data":[{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"},{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"},{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}]}

Replacing put with putSync has no impact on what happens.

Anyone who can shed some light onto this or point out what we’re doing wrong would be greatly appreciated.

Thanks and regards as always
Rob

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: dStore question

Rob Gillan-2
Missed saying that we normalise the nested @attributes field in the array before the put:

        for (i = 0; i < am.applets.length; i++) {
                entry['_id'] = am.applets[i]['_id'];
                for (o in am.applets[i]['@attributes']) {
                        entry[o] = am.applets[i]['@attributes'][o];
                }
                am.appletStore.put(entry, {overwrite: true});
        }

so each entry is a flat JSON structure


> On 23 Feb 2016, at 12:37 pm, Rob Gillan <[hidden email]> wrote:
>
> Hi all,
>
> About to try out 1.11 but before we do we are cutting over to dStore for our dGrids.  We are having some problems with data not being stored correctly.  We are using Trackable and Memory stores, with an idProperty of ‘_id’ (we are feeding it from Mongo so it makes things easy, this was how we did it with dojo/store as well).  It’s a very simple memory store to start.
>
> We have tried both put and putSync with the same result.
>
> We start with an array of data with two entries.
>
> am.applets: [{"_id":"56cbb096f3d117dc439bdb9e","@attributes":{"name":"am","title":"am","version":"100","id":"am","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}},{"_id":"56cbb0c2f3d117dc439bdb9f","@attributes":{"name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}}]
>
>
> We cycle through the array and put each entry into the store (with overwrite):
>
> am.appletStore = new TrackableMemoryStore({idProperty: '_id'});
>
> for (i = 0; i < am.applets.length; i++) {
> am.appletStore.put(am.applets[i], {overwrite: true});
> }
>
> When we inspect the store it shows the second entry appearing twice, rather than the two unique rows:
>
> am.appletStore:{"idProperty":"_id","storage":{"version":4,"fullData":[{"_id":"56cbb0c2f3d117dc439bdb9f","name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"},{"_id":"56cbb0c2f3d117dc439bdb9f","name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}],"index":{"56cbb096f3d117dc439bdb9e":0,"56cbb0c2f3d117dc439bdb9f":1}},"_inherited":{"p":2},"data":[{"_id":"56cbb0c2f3d117dc439bdb9f","name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"},{"_id":"56cbb0c2f3d117dc439bdb9f","name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}]}
>
> If we then receive an updated array of data and try and update the store:
>
> am.applets:[{"_id":"56cbb096f3d117dc439bdb9e","@attributes":{"name":"am","title":"am","version":"100","id":"am","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}},{"_id":"56cbb0c2f3d117dc439bdb9f","@attributes":{"name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}},{"_id":"56cbb2e6f3d117dc439bdba0","@attributes":{"name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}}]
>
> we would have expected running through the same update (put) loop it would have then had three unique rows in the store, but alas it has seemed to triplicate the last entry across all three positions (and obviously the grid shows that as well.
>
> am.appletStore:{"idProperty":"_id","storage":{"version":7,"fullData":[{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"},{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"},{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}],"index":{"56cbb096f3d117dc439bdb9e":0,"56cbb0c2f3d117dc439bdb9f":1,"56cbb2e6f3d117dc439bdba0":2}},"_inherited":{"p":2},"data":[{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"},{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"},{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}]}
>
> Replacing put with putSync has no impact on what happens.
>
> Anyone who can shed some light onto this or point out what we’re doing wrong would be greatly appreciated.
>
> Thanks and regards as always
> Rob
>
> --
> Dojo Toolkit: http://dojotoolkit.org/
> Tutorials: http://dojotoolkit.org/documentation/
>
> [hidden email]
> To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: dStore question

Kenneth G. Franqueiro
Trying to replicate what you said, it works completely fine for me:
http://jsfiddle.net/vzcywq2d/1/

--Ken

On 2/22/2016 8:40 PM, Rob Gillan wrote:

> Missed saying that we normalise the nested @attributes field in the array before the put:
>
> for (i = 0; i < am.applets.length; i++) {
> entry['_id'] = am.applets[i]['_id'];
> for (o in am.applets[i]['@attributes']) {
> entry[o] = am.applets[i]['@attributes'][o];
> }
> am.appletStore.put(entry, {overwrite: true});
> }
>
> so each entry is a flat JSON structure
>
>
>> On 23 Feb 2016, at 12:37 pm, Rob Gillan <[hidden email]> wrote:
>>
>> Hi all,
>>
>> About to try out 1.11 but before we do we are cutting over to dStore for our dGrids.  We are having some problems with data not being stored correctly.  We are using Trackable and Memory stores, with an idProperty of ‘_id’ (we are feeding it from Mongo so it makes things easy, this was how we did it with dojo/store as well).  It’s a very simple memory store to start.
>>
>> We have tried both put and putSync with the same result.
>>
>> We start with an array of data with two entries.
>>
>> am.applets: [{"_id":"56cbb096f3d117dc439bdb9e","@attributes":{"name":"am","title":"am","version":"100","id":"am","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}},{"_id":"56cbb0c2f3d117dc439bdb9f","@attributes":{"name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}}]
>>
>>
>> We cycle through the array and put each entry into the store (with overwrite):
>>
>> am.appletStore = new TrackableMemoryStore({idProperty: '_id'});
>>
>> for (i = 0; i < am.applets.length; i++) {
>> am.appletStore.put(am.applets[i], {overwrite: true});
>> }
>>
>> When we inspect the store it shows the second entry appearing twice, rather than the two unique rows:
>>
>> am.appletStore:{"idProperty":"_id","storage":{"version":4,"fullData":[{"_id":"56cbb0c2f3d117dc439bdb9f","name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"},{"_id":"56cbb0c2f3d117dc439bdb9f","name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}],"index":{"56cbb096f3d117dc439bdb9e":0,"56cbb0c2f3d117dc439bdb9f":1}},"_inherited":{"p":2},"data":[{"_id":"56cbb0c2f3d117dc439bdb9f","name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"},{"_id":"56cbb0c2f3d117dc439bdb9f","name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}]}
>>
>> If we then receive an updated array of data and try and update the store:
>>
>> am.applets:[{"_id":"56cbb096f3d117dc439bdb9e","@attributes":{"name":"am","title":"am","version":"100","id":"am","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}},{"_id":"56cbb0c2f3d117dc439bdb9f","@attributes":{"name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}},{"_id":"56cbb2e6f3d117dc439bdba0","@attributes":{"name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}}]
>>
>> we would have expected running through the same update (put) loop it would have then had three unique rows in the store, but alas it has seemed to triplicate the last entry across all three positions (and obviously the grid shows that as well.
>>
>> am.appletStore:{"idProperty":"_id","storage":{"version":7,"fullData":[{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"},{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"},{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}],"index":{"56cbb096f3d117dc439bdb9e":0,"56cbb0c2f3d117dc439bdb9f":1,"56cbb2e6f3d117dc439bdba0":2}},"_inherited":{"p":2},"data":[{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"},{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"
1.0","status":"active"},{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}]}

>>
>> Replacing put with putSync has no impact on what happens.
>>
>> Anyone who can shed some light onto this or point out what we’re doing wrong would be greatly appreciated.
>>
>> Thanks and regards as always
>> Rob
>>
>> --
>> Dojo Toolkit: http://dojotoolkit.org/
>> Tutorials: http://dojotoolkit.org/documentation/
>>
>> [hidden email]
>> To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
>
--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: dStore question

Rob Gillan-2
Ken,

As always thanks for your prompt response.  We’ve checked over our code a couple of times and basically all we’ve done is move from Observable/store-Memory to Trackable/dStore-Memory.  Will post what we find

Cheers
Rob

> On 23 Feb 2016, at 12:56 pm, Kenneth G. Franqueiro <[hidden email]> wrote:
>
> Trying to replicate what you said, it works completely fine for me:
> http://jsfiddle.net/vzcywq2d/1/
>
> --Ken
>
> On 2/22/2016 8:40 PM, Rob Gillan wrote:
>> Missed saying that we normalise the nested @attributes field in the array before the put:
>>
>> for (i = 0; i < am.applets.length; i++) {
>> entry['_id'] = am.applets[i]['_id'];
>> for (o in am.applets[i]['@attributes']) {
>> entry[o] = am.applets[i]['@attributes'][o];
>> }
>> am.appletStore.put(entry, {overwrite: true});
>> }
>>
>> so each entry is a flat JSON structure
>>
>>
>>> On 23 Feb 2016, at 12:37 pm, Rob Gillan <[hidden email]> wrote:
>>>
>>> Hi all,
>>>
>>> About to try out 1.11 but before we do we are cutting over to dStore for our dGrids.  We are having some problems with data not being stored correctly.  We are using Trackable and Memory stores, with an idProperty of ‘_id’ (we are feeding it from Mongo so it makes things easy, this was how we did it with dojo/store as well).  It’s a very simple memory store to start.
>>>
>>> We have tried both put and putSync with the same result.
>>>
>>> We start with an array of data with two entries.
>>>
>>> am.applets: [{"_id":"56cbb096f3d117dc439bdb9e","@attributes":{"name":"am","title":"am","version":"100","id":"am","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}},{"_id":"56cbb0c2f3d117dc439bdb9f","@attributes":{"name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}}]
>>>
>>>
>>> We cycle through the array and put each entry into the store (with overwrite):
>>>
>>> am.appletStore = new TrackableMemoryStore({idProperty: '_id'});
>>>
>>> for (i = 0; i < am.applets.length; i++) {
>>> am.appletStore.put(am.applets[i], {overwrite: true});
>>> }
>>>
>>> When we inspect the store it shows the second entry appearing twice, rather than the two unique rows:
>>>
>>> am.appletStore:{"idProperty":"_id","storage":{"version":4,"fullData":[{"_id":"56cbb0c2f3d117dc439bdb9f","name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"},{"_id":"56cbb0c2f3d117dc439bdb9f","name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}],"index":{"56cbb096f3d117dc439bdb9e":0,"56cbb0c2f3d117dc439bdb9f":1}},"_inherited":{"p":2},"data":[{"_id":"56cbb0c2f3d117dc439bdb9f","name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"},{"_id":"56cbb0c2f3d117dc439bdb9f","name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}]}
>>>
>>> If we then receive an updated array of data and try and update the store:
>>>
>>> am.applets:[{"_id":"56cbb096f3d117dc439bdb9e","@attributes":{"name":"am","title":"am","version":"100","id":"am","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}},{"_id":"56cbb0c2f3d117dc439bdb9f","@attributes":{"name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}},{"_id":"56cbb2e6f3d117dc439bdba0","@attributes":{"name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}}]
>>>
>>> we would have expected running through the same update (put) loop it would have then had three unique rows in the store, but alas it has seemed to triplicate the last entry across all three positions (and obviously the grid shows that as well.
>>>
>>> am.appletStore:{"idProperty":"_id","storage":{"version":7,"fullData":[{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"},{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"},{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}],"index":{"56cbb096f3d117dc439bdb9e":0,"56cbb0c2f3d117dc439bdb9f":1,"56cbb2e6f3d117dc439bdba0":2}},"_inherited":{"p":2},"data":[{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"},{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"
> 1.0","status":"active"},{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}]}
>>>
>>> Replacing put with putSync has no impact on what happens.
>>>
>>> Anyone who can shed some light onto this or point out what we’re doing wrong would be greatly appreciated.
>>>
>>> Thanks and regards as always
>>> Rob
>>>
>>> --
>>> Dojo Toolkit: http://dojotoolkit.org/
>>> Tutorials: http://dojotoolkit.org/documentation/
>>>
>>> [hidden email]
>>> To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
>>
> --
> Dojo Toolkit: http://dojotoolkit.org/
> Tutorials: http://dojotoolkit.org/documentation/
>
> [hidden email]
> To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: dStore question

Rob Gillan-2
In reply to this post by Kenneth G. Franqueiro
ok, bit rusty it seems.  As we normalised the entries to a single row someone (read me) forgot to initialise the entry each time through the loop

All good now, thanks

> On 23 Feb 2016, at 12:56 pm, Kenneth G. Franqueiro <[hidden email]> wrote:
>
> Trying to replicate what you said, it works completely fine for me:
> http://jsfiddle.net/vzcywq2d/1/
>
> --Ken
>
> On 2/22/2016 8:40 PM, Rob Gillan wrote:
>> Missed saying that we normalise the nested @attributes field in the array before the put:
>>
>> for (i = 0; i < am.applets.length; i++) {
>> entry['_id'] = am.applets[i]['_id'];
>> for (o in am.applets[i]['@attributes']) {
>> entry[o] = am.applets[i]['@attributes'][o];
>> }
>> am.appletStore.put(entry, {overwrite: true});
>> }
>>
>> so each entry is a flat JSON structure
>>
>>
>>> On 23 Feb 2016, at 12:37 pm, Rob Gillan <[hidden email]> wrote:
>>>
>>> Hi all,
>>>
>>> About to try out 1.11 but before we do we are cutting over to dStore for our dGrids.  We are having some problems with data not being stored correctly.  We are using Trackable and Memory stores, with an idProperty of ‘_id’ (we are feeding it from Mongo so it makes things easy, this was how we did it with dojo/store as well).  It’s a very simple memory store to start.
>>>
>>> We have tried both put and putSync with the same result.
>>>
>>> We start with an array of data with two entries.
>>>
>>> am.applets: [{"_id":"56cbb096f3d117dc439bdb9e","@attributes":{"name":"am","title":"am","version":"100","id":"am","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}},{"_id":"56cbb0c2f3d117dc439bdb9f","@attributes":{"name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}}]
>>>
>>>
>>> We cycle through the array and put each entry into the store (with overwrite):
>>>
>>> am.appletStore = new TrackableMemoryStore({idProperty: '_id'});
>>>
>>> for (i = 0; i < am.applets.length; i++) {
>>> am.appletStore.put(am.applets[i], {overwrite: true});
>>> }
>>>
>>> When we inspect the store it shows the second entry appearing twice, rather than the two unique rows:
>>>
>>> am.appletStore:{"idProperty":"_id","storage":{"version":4,"fullData":[{"_id":"56cbb0c2f3d117dc439bdb9f","name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"},{"_id":"56cbb0c2f3d117dc439bdb9f","name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}],"index":{"56cbb096f3d117dc439bdb9e":0,"56cbb0c2f3d117dc439bdb9f":1}},"_inherited":{"p":2},"data":[{"_id":"56cbb0c2f3d117dc439bdb9f","name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"},{"_id":"56cbb0c2f3d117dc439bdb9f","name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}]}
>>>
>>> If we then receive an updated array of data and try and update the store:
>>>
>>> am.applets:[{"_id":"56cbb096f3d117dc439bdb9e","@attributes":{"name":"am","title":"am","version":"100","id":"am","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}},{"_id":"56cbb0c2f3d117dc439bdb9f","@attributes":{"name":"cm","title":"cm","version":"089","id":"cm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}},{"_id":"56cbb2e6f3d117dc439bdba0","@attributes":{"name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}}]
>>>
>>> we would have expected running through the same update (put) loop it would have then had three unique rows in the store, but alas it has seemed to triplicate the last entry across all three positions (and obviously the grid shows that as well.
>>>
>>> am.appletStore:{"idProperty":"_id","storage":{"version":7,"fullData":[{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"},{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"},{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}],"index":{"56cbb096f3d117dc439bdb9e":0,"56cbb0c2f3d117dc439bdb9f":1,"56cbb2e6f3d117dc439bdba0":2}},"_inherited":{"p":2},"data":[{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"},{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"
> 1.0","status":"active"},{"_id":"56cbb2e6f3d117dc439bdba0","name":"dm","title":"dm","version":"009","id":"dm","domain":"all","type":"browser","privilege":"","spec":"1.0","status":"active"}]}
>>>
>>> Replacing put with putSync has no impact on what happens.
>>>
>>> Anyone who can shed some light onto this or point out what we’re doing wrong would be greatly appreciated.
>>>
>>> Thanks and regards as always
>>> Rob
>>>
>>> --
>>> Dojo Toolkit: http://dojotoolkit.org/
>>> Tutorials: http://dojotoolkit.org/documentation/
>>>
>>> [hidden email]
>>> To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
>>
> --
> Dojo Toolkit: http://dojotoolkit.org/
> Tutorials: http://dojotoolkit.org/documentation/
>
> [hidden email]
> To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest