Using the packaged ydn-db library from here: http://git.yathit.com/ydn-db/downloads/ydn.db-jquery-0.7.12.js . Same happens with https://storage.cloud.google.com/download.yathit.com/ydn-db/build/zsk-ydn.db-dev-0.7.15.js .
var db = new ydn.db.Storage("mydb");
var clog = function(r) { console.log(r); }
db.put({name: "store1", keyPath: "id"}, {id: "id1", value: "value1"});
db.put({name: "store1", keyPath: "id"}, {id: "id2", value: "value2"});
db.get("store1", "id1").done(clog); // works fine
// Example as mentioned in the docs here: http://dev.yathit.com/ydn-db/getting-started.html
var reverse = false, limit = 10;
db.values(new ydn.db.Cursors("store1", "id", null, reverse), limit).done(clog)
// TypeError: Cannot call method 'getName' of null
// Also adapted from docs:
db.values(ydn.db.IndexValueCursors.where("store1", "id", "=", "id1")).done(clog)
// TypeError: Cannot call method 'getName' of null
// Also adapted from docs:
var iter = new ydn.db.ValueCursors("store1", ydn.db.KeyRange.starts("a"))
db.open(iter, clog, "readwrite")
// ydn.error.ArgumentException: Second argument must be cursor range iterator.
The functionality of the packaged library just doesn't seem to align with the docs. Any tips?
Ok, finally got it from the link in the previous answer:
// Equivalent to: SELECT * FROM store1 where value = 'value1':
var keyRange = ydn.db.KeyRange.only("value1");
var cursor = new ydn.db.IndexValueCursors("store1", "value", keyRange);
db.get(cursor, keyRange).then(function(record) {
console.log("record:", record);
}, function(err) {
throw err;
});