Helper library to clean a PostgreSQL, MySQL or SQLite3 database tables using Knex. Great for integration tests.
npm install knex-cleaner
var knexCleaner = ;var knex =client: 'mysql'connection:host : '127.0.0.1'user : 'your_database_user'password : 'your_database_password'database : 'myapp_test';knexCleaner;// You can also use this in BookshelfJSvar bookshelf = knex;knexCleaner;// You can also pass if it deletes the tables with delete instead of truncate// as well as a list of tables to ignore.var options =mode: 'delete' // Valid options 'truncate', 'delete'ignoreTables: 'Dont_Del_1' 'Dont_Del_2'knexCleaner;
The example above used MySQL but it has been tested on PostgreSQL and SQLite3.