私はDexieJSを使用して IndexedDB からデータを取得しています。v. 1.1.0 と 1.2.0 の両方で次のテストを行いました。
単純なクエリにはうまく機能しますが、残念ながら、複数の where 句をチェーンすることはできません。
まず、これを試してみました
var collection = db[table];
collection = collection.where('Field').equals("1");
return collection.count();
そして、それは機能していました。次に、where 句を追加する必要がありますが、特定の値が設定されている場合のみです。
var collection = db[table];
collection = collection.where('Field').equals("1");
if(value) collection = collection.where('Field2').above(value);
return collection.count();
これは失敗します。テスト目的で、私も試しました:
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();
これらのどれも機能しません。これは絶対にありえないと思い始めていますが、メソッドand()
が存在するのであれば、方法があるに違いありません。
PSこれは機能します:
var collection = db[table];
collection = collection.where('Field2').above(value);
return collection.count();