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

241
Visualizações
I want to change my dexie values which are null to empty strings

I want to change my data-tables values which are null to empty strings.

Sometimes the department value will be empty, in which case it will put null in my data tables.

db = db_open();

db.fuel.toArray().then(fuel => {
  fuel.forEach(function(fuel) { 
    $('#table_bod').append('<tr> <td>'+fuel.department+'</td> </tr> ');
  })
});

I tried:

const fuels = db.fuel.where({department: null});

But that doesn't seem to work.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

IndexedDB cannot match against null so in order to find those you must do a full table scan.

const fuelsWithoutDepartment = await db.fuel
  .filter(x => x.department === null)
  .toArray();

Create an upgrader that modifies all null departments to empty string in case you want to have that instead of null.

db.version(2).stores({
  fuel: 'id, department'
}).upgrade (tx => {
  return tx.fuel.filter(
    x => x.department === null
  ).modify({department: ""});
});

Once you've declared such an upgrader (please adjust it to the appropriate version, id and indexes for your case), then you won't need a full table scan to find fuels without departments anymore but can use the department index (if you have one):

const fuelsWithoutDepartment = await db.fuel
  .where({department: ""})
  .toArray();
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