PDA

View Full Version : [CLOSED] Store Sync order of operations



cwolcott
Nov 08, 2013, 3:56 AM
Is there a way to change the order of operations for Store sync? I am using a store with an AjaxProxy. It looks like the process order is new records, updated records, then deleted records.

I would think that you would want to first process deleted records then anything else.

The example is:

I delete a record in the Grid with the Name field of 'Microsoft', which is a unique constraint. Before syncing the store I add a new record with a name field of 'Microsoft'. Since the process order is New, Update, Delete the new record fails to insert, but then the deleted record is removed and I now have no 'Microsoft record.

Just curious ...

Daniil
Nov 08, 2013, 4:36 AM
Hi Chris,

Please use an AjaxProxy's BatchOrder.
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.data.proxy.Proxy-cfg-batchOrder

cwolcott
Nov 08, 2013, 2:45 PM
This works just like I want it. At least one other person asked about this.

Store batch order (http://forums.ext.net/showthread.php?23752-Store-batch-order&highlight=batchOrder)

It seems weird that the default is 'create,update,delete' instead of 'delete,update,create'.

Please close.

Daniil
Nov 11, 2013, 6:23 AM
Let's try to opposite your scenario, this one:


I delete a record in the Grid with the Name field of 'Microsoft', which is a unique constraint. Before syncing the store I add a new record with a name field of 'Microsoft'. Since the process order is New, Update, Delete the new record fails to insert, but then the deleted record is removed and I now have no 'Microsoft record.

with your new batchOrder.

So, "I create a record in the GridPanel with the Name field of 'Microsoft', which is a unique constraint. Before syncing the store I delete that record with a name field of 'Microsoft'. Since the process order is Delete, Update, Create the record is deleted, then created. Expected - no 'Microsoft' record', in fact - we have 'Microsoft' record."

Does that make sense?

cwolcott
Nov 11, 2013, 1:29 PM
So, "I create a record in the GridPanel with the Name field of 'Microsoft', which is a unique constraint. Before syncing the store I delete that record with a name field of 'Microsoft'. Since the process order is Delete, Update, Create the record is deleted, then created. Expected - no 'Microsoft' record', in fact - we have 'Microsoft' record."

Does that make sense?

No I doesn't make sense, because the record will never be inserted into the database. Here are the steps:

1) Create record in the GridPanel with the name field 'Microsoft'.

The record exists in the store and is in the newRecords object.

2) Before syncing the store I delete that record with the name field of 'Microsoft'.

The record is removed from the store and is no longer in the newRecords object.

3) Now we sync the store, but there are no changes.

Does this make sense?

Daniil
Nov 11, 2013, 4:20 PM
Hmm.

Do you mean IDProperty under "a unique constraint"?

cwolcott
Nov 11, 2013, 5:18 PM
Hmm.

Do you mean IDProperty under "a unique constraint"?

No. There is an ID column that is the IDProperty and is defined as an identity column in the database. The Name column is just a unique contraint in the database. So there should be only one row in the DB with 'Microsoft'. I currently do not perform any checks in the Grid when the data is added/edited. I let the StoreResponse return an exception if there is one.

Again everything is working perfectly for me, once I reversed the BatchOrder. I could work up an example, but it couldn't be run because we would have no backend database.

Daniil
Nov 14, 2013, 5:36 AM
I could work up an example, but it couldn't be run because we would have no backend database.

No need, thanks.

Well, it makes sense what you are talking about.

Though, maybe, there are other possible scenarios which proves the current default batchOrder. I mean that ExtJS mean somehow picked that order. Maybe, they were wrong, but, anyway, they provided an option to change the order. It looks good enough.

I would prefer to leave this issue as it is for now if you don't mind. But I will keep it in mind.

cwolcott
Nov 14, 2013, 1:16 PM
Please close the thread. I wasn't asking for anything to change and I am glad that they have an option for use to change the order to meet the developers needs.

Daniil
Nov 14, 2013, 2:21 PM
I wasn't asking for anything to change

I am always craving to improve something by myself as well:)