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

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

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 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