Miss any of our Open RFC calls?Watch the recordings here! »

knex-tablecleaner

3.1.2 • Public • Published

knex-tablecleaner

Simple library for deleting all rows from a given list of DB tables. Tables are cleaned sequentially in a given order to avoid foreign key constraint violations.

Example usage:

const tableCleaner = require('knex-tablecleaner');
const knex = require('../db');
 
const defaultTablesToClean = [
  'orders',
  'users'
];
 
function cleanDb(tablesToClean = defaultTablesToClean) {
  return tableCleaner.cleanTables(knex, tablesToClean);
}
 
module.exports = {
  cleanDb,
};

Keywords

none

Install

npm i knex-tablecleaner

DownloadsWeekly Downloads

977

Version

3.1.2

License

none

Unpacked Size

14.4 kB

Total Files

7

Last publish

Collaborators

  • avatar