Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
knex-cleaner
Advanced tools
Readme
Helper library to clean a PostgreSQL, MySQL or SQLite3 database tables using Knex. Great for integration tests.
npm install knex-cleaner
var knexCleaner = require('knex-cleaner');
var knex = require('knex')({
client: 'mysql',
connection: {
host : '127.0.0.1',
user : 'your_database_user',
password : 'your_database_password',
database : 'myapp_test'
}
});
knexCleaner.clean(knex).then(function() {
// your database is now clean
});
// You can also use this in BookshelfJS
var bookshelf = require('bookshelf')(knex);
knexCleaner.clean(bookshelf.knex).then(function() {
});
// 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'
restartIdentity: true, // Used to tell PostgresSQL to reset the ID counter
ignoreTables: ['Dont_Del_1', 'Dont_Del_2']
}
knexCleaner.clean(knex, options).then(function() {
// your database is now clean
});
The example above used MySQL but it has been tested on PostgreSQL and SQLite3.
FAQs
Database cleaner for Knex.js and bookshelf.js
The npm package knex-cleaner receives a total of 14,918 weekly downloads. As such, knex-cleaner popularity was classified as popular.
We found that knex-cleaner demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.