Reputation: 19
I am developing an web app. Therefore I use Sencha Touch 2 and for ydn db for local storage.
My question is, how can I fetch data from ydn db by 2 or more conditions? For example username=Moo and street = Teststreet and lastname = 'xy'?
Thanks for replies. :-)
Upvotes: 0
Views: 277
Reputation: 4153
Here's I how do it using scan() but hopefully .where().where() will be implemented soon.
var iters, key_range, result, solver;
iters = [];
key_range = ydn.db.KeyRange.only(18);
iters.push(new ydn.db.IndexIterator('person', 'age', key_range));
key_range = ydn.db.KeyRange.only('F');
iters.push(new ydn.db.IndexIterator('person', 'sex', key_range));
result = [];
solver = new ydn.db.algo.NestedLoop(result);
db.scan(solver, iters).then(function() {
console.log(result);
});
I based this example from here https://github.com/yathit/ydn-db/blob/master/test/qunit/cursor.js#L929-L943
Hope that helps.
Upvotes: 2