Get keys with their values from object store with YDN-DB

179 views Asked by At

I know how to get object values with YDN-DB from an object store but is it also possible to get these values together with their primary keys?

1

There are 1 answers

2
Kyaw Tun On

Common ydn-db query method does not return both keys and values. You have to use either scan or open methods, which operates on cursors.

Base on the db.open API example:

var iter = ydn.db.ValueIterator.where('player', 'clad', '=', 'hobbit');
var req = db.open(function(icursor) {
  var player = icursor.getValue();
  var key = icursor.getKey(); // this must be 'hobbit'
  var primary = icursor.getPrimaryKey(); 
  ...

See icursor API for detail.