'How to delete all records in table without condition using knex?
Question is kinda simple. I want to delete all rows from my table using knex, but without conditions.
await knex('my_table')
.del().where()
Method .del() uses condition. Is it possible? Or is there any SQL syntax to do that?
Solution 1:[1]
If you want to delete all rows, you just need to use .del() without any where condition.
await knex('my_table').del()
Note that it will not delete the table. It will delete all the rows in the table.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Berkay Berabi |
