Skip to content
Small query framework for IndexedDB
Find file
New pull request
Failed to load latest commit information.
README add some docs
TODO some more ideas
test.html Initial test harness.
test.js Fix IDBKeyRange usage issue. Thanks to Jonas Sicking for pointing it …
testglue.js Even more concise way of spelling tests.


A small query library for IndexedDB

Query construction

A query consists of the name of an index, an operation, and a
comparison value. This is how you construct a query:

  Index("make").oneof("BMW", "Volkswagen")

This will return all objects whose "make" index value is
either "BMW" or "Volkswagen". Available operations are:

  * eq
  * lt, lteq
  * gt, gteq
  * between, betweeq
  * oneof

It is possible to link queries with boolean operations, e.g.:


Getting results

Getting results from a query works very much like getting results from
a single index in IndexedDB. You have the option of a cursor, e.g.:

  let cars = [];
  let store = transaction.objectStore("cars");
  let request = query.openCursor(store);
  request.onsuccess = function (event) {
    let cursor = request.result;
    if (cursor) {

or simply getting all values at once:

  let cars;
  let request = query.getAll(store);
  request.onsuccess = function (event) {
    cars = request.result;

`query.openKeyCursor` and `query.getAllKeys` are also available if
just the keys are of interest.
Something went wrong with that request. Please try again.