Developer89
Developer89

Reputation: 19

How to fetch data from ydn-db with multiple conditions

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

Answers (2)

paolooo
paolooo

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

Kyaw Tun
Kyaw Tun

Reputation: 13151

Read this doc. Currently it is not easy.

Upvotes: 0

Related Questions