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

236
Views
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 answers
Answer question

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