Interface ydn.db.ICursor

Cursors are a transient mechanism used to iterate on stream of ordered records from a store. cursor

Cursors are obtained by opening an iterator. Opening a key iterator enumerate key cursors while opening a value iterator enumerate value cursors. Key cursor is read only and does not have value. Enumerating key cursor is much faster than value cursor and commonly used in filter and join query.

var iter = new ydn.db.ValueIterator('player');
db.open(iter, function next(icursor) {
  var v = icursor.value();
  if (v.amount < 50) {
     v.amount += 10;
     icursor.update(v);
  }
});

Methods
getKey(i)
Get effective key of the cursor for respective store.
The ordering is same as ordering of peers on the query object. 
Parameters:
{number=} i
Optional.Store index. Default to 0 for base store.
Returns:
{*|undefined} Effective key.

getPrimaryKey(i) 
Get primary key of the cursor for respective store.
The ordering is same as ordering of peers on the query object.
Parameters:
{number=} i
Optional. Store index. Default to base store.
Returns:
{*|undefined} Current primary key.

clear(i)
Clear record for value cursor.
Parameters:
{number=} i
Optional. Store index.
Returns:
{!goog.async.Deferred.<number>} return number of records cleared in a deferred object.

merge()
Merge cursor values into single object.
Merging is performed by replacing on field name with cursor value of a peer store.
Returns:
{!Object} Merged cursor value.


update(value, i)
Update current record for value cursor.
Parameters:
{*} value
Value to update.
{number=} i
Optional. Store index.
Returns:
{!goog.async.Deferred} return updated primary key in a deferred object.

getValue(i)
Get cursor value of a value cursor.
Should it required the value to be retained beyond iteration function callback scope, the value must be cloned to prevent disposal.
The ordering is same as ordering of peers on the query object.
Parameters:
{number=} i
Optional.Store index. Default to 0 for base store.
Returns:
{*|undefined} Record value of the cursor. This is undefined for key cursor.