Results 1 to 3 of 3

Thread: Local Storage keeping multiple instance of the same id

  1. #1
    Sencha User
    Join Date
    Feb 2012
    Location
    Illinois
    Posts
    97
    Vote Rating
    2
      0  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3932
    Vote Rating
    1272
      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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Feb 2012
    Location
    Illinois
    Posts
    97
    Vote Rating
    2
      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
            }.....

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •