1. #1
    Sencha User
    Join Date
    Feb 2012
    Location
    Illinois
    Posts
    93
    Vote Rating
    2
    bwags is on a distinguished road

      0  

    Default Unanswered: Local Storage keeping multiple instance of the same id

    Unanswered: Local Storage keeping multiple instance of the same id


    So I read this in another thread (but couldn't get a response).....

    Basically the discussion is about persisting a single object (like a user settings object) via a local storage proxy.

    Quote Originally Posted by mrsunshine View Post
    you can check the count of the store and work with a record with the same ID, should be only one record in the store. so if no record exist create one otherwise work with the existing one
    I'm doing this, but notice that if I check the Resources tab in Chrome's Developer Tools under LocalStorage -> localhost, I can see that there are entries for both 'myUniqueProxy' and 'myUniqueProxy-0' (I set the id to the model to be 0).

    There are never any more entries in 'myUniqueProxy-0' other than the one I want, however it looks like there are tons entries for '0' in 'myUniquProxy'. Apparently one for every save despite it being the same record.

    Here's an image of what I'm seeing (don't pay attention to any malformed data, I modified it for this post):

    Attachment 36351

    My proxy is setup like this:
    Code:
            proxy : {
                type : 'localstorage',
                id : 'myUniqueProxy',
            }
    My Model has an id field like this:
    Code:
           {
                name : 'id',
                type : 'integer',
                defaultValue : 0,
                isUnique : true
            }
    Then just like you said, I call for the store to getRecordById(0), update that record with current data and save it.

    Am I doing something wrong to get so many entries in the 'myUniqueProxy' entry?

    Thanks in advance for any advice.

    bwags

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,549
    Vote Rating
    873
    Answers
    3567
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Let me see if I understand something, when you add data to your store the data includes a value for id?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Feb 2012
    Location
    Illinois
    Posts
    93
    Vote Rating
    2
    bwags is on a distinguished road

      0  

    Default


    Yes, it always includes a value for id.

    This is how I define my id:

    Code:
    fields : [ {
                name : 'id',
                type : 'integer',
                defaultValue : 0,
                isUnique : true
            }.....

Thread Participants: 1

Tags for this Thread