使用带有knex的where()插入现有行

卡里亚托

我想使用knex.js将数据插入到现有行中,但在文档中看不到它很清楚,请尝试使用Where(),因为下面的代码不起作用。我已经看到有一个名为knex-filter的npm软件包可能对此有所帮助,但是我想应该有一种使用knex.js的方法。如果有人知道如何进行操作,我将非常感激。

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

我认为您应该使用更新而不是插入

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章