Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

222
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda