1. #1
    Sencha User DrunkenBeard's Avatar
    Join Date
    May 2011
    Posts
    55
    Answers
    2
    Vote Rating
    -2
    DrunkenBeard has a little shameless behaviour in the past

      0  

    Default Unanswered: Autoincrement field and Store.sync

    Unanswered: Autoincrement field and Store.sync


    Hi,

    Right now I have a problem with the way Sencha stores work. I have a model that I persist to a remote table. The table has an autoincrement id. When I create a new record and add it, Sencha creates it in the store and gives it a "ext-record-X" id. The autoincrement is handled in the server, that's not a problem, but should I update the id of the record in the store when the insert is successful ? If I don't, then how can I modify that record ? I don't know its id, and the server has no way to know that "ext-record-5" is actually the record with id = 45.

    I'm not sure I'm being clear. My problem is that the remote database identifies records with different IDs than the Sencha stores, so it makes modifying and deleting records from the store difficult to sync with the database. If I update the id of the record after each successful insert it would solve the problem but it would still introduce two other problems :

    1. The record would become dirty when it's not really dirty
    2. There would be a time gap (when waiting for the server's response) where you can't update or delete the record even though it's there in the store.

    Any suggestions ?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,811
    Answers
    3467
    Vote Rating
    834
    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


    When you sync your store so the server then inserts the data in the database, what do you respond with?
    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 DrunkenBeard's Avatar
    Join Date
    May 2011
    Posts
    55
    Answers
    2
    Vote Rating
    -2
    DrunkenBeard has a little shameless behaviour in the past

      0  

    Default


    Hi mitchell,

    I figure I should respond with the inserted record? How about batch operations? Should I respond then with an array of records? And if there is only one added record, can I still respond with an array of one element?

    Thanks

Thread Participants: 1