Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

219
Views
index.getAll() on indexedDB returns empty array

IndexedDB noob here...

const queueStore = db.createObjectStore("queue", { keyPath: "id", autoIncrement: true });
queueStore.createIndex("HasBeenSent", ["sent"], { unique: false });

I am queuing data, awaiting an upload to a server at a later time, so for now the "sent" value is zero for each record; I'll update the record to reflect "sent" equals 1 later.

When I try to get all the records where the value of "sent" is zero, I get an empty result, using

request = db.transaction('queue').objectStore('queue').index('HasBeenSent').getAll(0);

If I remove the zero and just have empty brackets, I get all the rows in the store, but if I include any value in the brackets (0, 1, -1, etc) every time I get empty results, even if I definitely have stored records with those values.

(Have I messed something up in the configuration?)

How do I query the store to return all rows where "sent" equals zero??

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I read through various sources that getAll() is ok on small datasets, but it can be slow and hungry on large datasets, so I decided to use cursors which should perform better on both large and small datasets. But, I ran into the same issue with empty results.

What didn't work:

const request = db.transaction('queue').objectStore('queue').index('sent').openCursor(0);

nor

const request = db.transaction('queue').objectStore('queue').index('sent').openCursor(IDBKeyRange.only(0));

What DID work

const keyrange = IDBKeyRange.only(0);
const request = db.transaction('queue').objectStore('queue').index('sent').openCursor(keyrange);

I imagine (but never tested) that using getAll(), you'd need to do something similar by defining the keyrange first, then including that in the getAll() request, like

const keyrange = IDBKeyRange.only(0);
const request = db.transaction('queue').objectStore('queue').index('sent').getAll(keyrange);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!