karliatto karliatto - 8 months ago 37
MySQL Question

insert into existing row using where() with knex

I want to insert data into an existing row with knex.js but I do not see it is clear in the documentation, trying with Where() as in the code below doesn't work. I've seen that there is a npm package called knex-filter that may help in doing so, but I guess there should be a way to do it with knex.js
If anyone knows how to proceed I would be very gratefull.

.where({id : petId})
.insert({image: file.path})
.then(function(result) {
console.log('knexjs works!!');
.catch(function(error) {


I think you should use update instead of insert

.where('id', petId)
.update({image :file.path})