0

I have a NodeJS server that runs Express and SQLITE.

When I do:

    const knexx = await knex('Users')
        .where({id: user.id})
        .update({ password: pwhashed }).toString()
    console.log(knexx)

Somehow it prints:

update set password = '$2a$08$/qIkAQfaqzkwtXHyV.94S.YJ8OMx0e8nrySW6idCueZIT/f5rdU4K' where id = 1

The queries are missing table names. When I get rid of .toString, it gives me:

{ [Error: SQLITE_ERROR: near "set": syntax error] errno: 1, code: 'SQLITE_ERROR' }
user6269972
  • 199
  • 1
  • 11

1 Answers1

0

IMHO this implicates that the table Users doesn't exist (or what is less possible knexjs expects it should be written in lowercases even if SQLite table names are case insensitive), this could be easily checked using:

knex.schema.hasTable('Users').then(function(exists) {
  if (!exists) {
       console.log('table doesnt exist');
    });
  }
});