Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

220
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda