This post is all about of deleting records through KNEX ORM in Nodejs. The following code shows how to achieve this:
knex("depts").where("deptno","50").del()
.then(function (count) {
console.log(count);
})
.finally(function () {
knex.destroy();
});
The above code deletes a record from a table "Depts" where Deptno = 50. It has a "then" Promise attached that will show how many records were deleted with this command.
Also "finally" is the method that will always execute and will close the KNEX connection.
Happy Coding !!!
knex("depts").where("deptno","50").del()
.then(function (count) {
console.log(count);
})
.finally(function () {
knex.destroy();
});
The above code deletes a record from a table "Depts" where Deptno = 50. It has a "then" Promise attached that will show how many records were deleted with this command.
Also "finally" is the method that will always execute and will close the KNEX connection.
Happy Coding !!!
Comments