6 Sep 2012 2:27 AM #1
Unanswered: Autoincrement field and Store.sync
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 ?
8 Sep 2012 6:18 AM #2
- Join Date
- Mar 2007
- Gainesville, FL
- Vote Rating
When you sync your store so the server then inserts the data in the database, what do you respond with?
Sencha Inc, Senior Software Engineer
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
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 email@example.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.
8 Sep 2012 10:00 AM #3
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?