I'm using DexieJS to fetch data from an IndexedDB. I've done the following tests both with v. 1.1.0 and 1.2.0.
It is working great for simple queries, but unfortunately I am unable to chain multiple where clauses.
First, I've tried this
var collection = db[table];
collection = collection.where('Field').equals("1");
return collection.count();
And that was working. Then, I need to add a where clause, but only if a given value is set:
var collection = db[table];
collection = collection.where('Field').equals("1");
if(value) collection = collection.where('Field2').above(value);
return collection.count();
This one fails. For test purposes, I've also tried:
var collection = db[table];
collection = collection.where('Field').equals("1")
.and('Field2').above(value);
return collection.count();
var collection = db[table];
collection = collection.where('Field').equals("1")
.and().where('Field2').above(value);
return collection.count();
var collection = db[table];
collection = collection.where('Field').equals("1")
.where('Field2').above(value);
return collection.count();
None of these work. I'm starting to think that this is not possible at all, but since the method and()
exists, there must be a way!
PS this works:
var collection = db[table];
collection = collection.where('Field2').above(value);
return collection.count();