Assuming you have the following records in an objectStore objStore:

Record #1: {prop1: 1, prop2: "foo1"}
Record #2: {prop1: 2, prop2: "foo2"}
Record #3: {prop1: 3, prop2: "foo3"}
Record #4: {prop1: 4, prop2: "foo4"}

keyPath = "prop1"

Now, we create an index on "prop2" called index1. 

Let's say get a cursor on index1 and we start iterating through it.
When I get to Record #2, I decide to use the cursor index to call update and 
change prop2 to "foo5":

          var rq = objStore.index("index1").openCursor();
          rq.onsuccess = function (evt) {
              var cursor = evt.target.result;
                 if (cursor) {
                     if (cursor.value.prop1 == "foo2") {
                         var rq2 = cursor.update({prop1: 2, prop2: "foo5"});
                     }
                    cursor.continue();
                }
          };

My question is what is going to happen to the cursor position when the update 
takes place?

Our expectation is that the cursor value will remain unchanged in the client 
code while the database object entry (i.e. record) will change.
This will produce the following values for cursor.key and cursor.primaryKey 
"foo2" and "2", respectively.  
Thus, we expect the cursor position to remain unchanged and continue() should 
return Record #3.  
Additionally, we expect to see the new Record #2 entry after Record #4.

Do you agree?

Israel

Reply via email to