npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

dbtasker

v2.5.1

Published

You can create database and table on your own with a lot of functionality.

Readme

DBTASKER

DBTASKER is a powerful MySQL schema intelligence and query generation module. It allows developers to define database schemas declaratively in JSON. DBTASKER automatically validates, normalizes, and generates correct SQL for tables, columns, indexes, defaults, foreign keys, and more. It is engine-aware, handles MySQL constraints, and is fully compatible with ORMs or other automation tools.

Engine Awareness

DBTASKER supports MySQL engines and handles constraints accordingly:

  • InnoDB
  • MyISAM
  • MEMORY
  • CSV
  • ARCHIVE
  • BLACKHOLE
  • FEDERATED
  • NDB / NDBCLUSTER
  • MRG_MYISAM
  • Spider
  • RocksDB
  • TokuDB

Design Philosophy

  • Schema-first, declarative JSON
  • Validation before SQL generation
  • Engine-aware and safe migrations
  • Flexible key aliases and metadata support
  • Supports both SQL-level and ORM-level annotations

Compatibility

  • Node.js 16+
  • MySQL 5.7+ / 8+

Core Concept

DBTASKER uses a JSON-driven design:

Database → Tables → Columns → Column Properties
  • Database: Name of the MySQL database
  • Table: Table within the database
  • Column: Column within the table
  • Properties: Rules, types, defaults, and constraints

DBTASKER normalizes keys case-insensitively, so multiple naming styles are supported (camelCase, snake_case, uppercase, lowercase).

JSON Schema Structure

{
  DatabaseName: {
    TableName: {
      ColumnName: {
        // Column properties
      }
    }
  }
}

Demo Schema Example

{
  DatabaseName: {
    TableName: {
      ColumnName: {
        ColumnType: "varchar",
        lengthvalue: 255,
        Null: true,
        defaults: "guest",
        comment: "User email address"
      },
      ColumnTwo: {
        type: "int",
        zerofill: true,
        index: "key",
        Null: false,
        foreign_key: {
          table: "user",
          column: "id",
          delete: true,
          update: true
        }
      }
    }
  }
}

Configuration File

DBTASKER requires a configuration JSON file to connect to your MySQL database and define runtime behavior. This config file allows you to:

  • Set database connection credentials
  • Control whether databases, tables, or columns are dropped
  • Protect specific databases from accidental deletion
  • Customize separators or other runtime options

Basic Database Configuration

{
  user: "root",
  password: "password123",
  host: "localhost",
  port: 3306
}
  1. user: MySQL username
  2. password: MySQL password
  3. host: MySQL host
  4. port: MySQL port
  5. Drop database
  6. Do not delete database Array = []
  7. Drop Table
  8. Drop Column
  9. Database structure as JSON Object

You can control dropping databases, tables, or columns using boolean flags. DBTASKER supports multiple aliases for each option.

Drop Database

Aliases:

You can use these as key when declearing on config JSON object without caring for case sensitivity.

dropdb, dropdatabase, deletedb, deletedatabase,
drop_db, drop_database, delete_db, delete_database,
removedb, removedatabase, remove_db, remove_database

Example:

dropdb: true

Drop Table

Aliases: You can use these as key when declearing on config JSON object without caring for case sensitivity.

droptable, deletetable, drop_table, delete_table,
removetable, remove_table,
dropdbtable, deletedbtable, removedbtable,
dropdatabasetable, deletedatabasetable, removedatabasetable,
drop_db_table, delete_db_table, remove_db_table,
drop_database_table, delete_database_table, remove_database_table

Example:

droptable: true

Drop Column

Aliases: You can use these as key when declearing on config JSON object without caring for case sensitivity.

dropcol, dropcolumn, deletecol, deletecolumn,
removecol, removecolumn,
drop_col, drop_column, delete_col, delete_column,
remove_col, remove_column

Example:

dropcol: false

Protect Databases from Deletion If you want to prevent certain databases from being dropped when dropdb is enabled, you can specify an array of database names under any of the aliases below: You can use these as key when declearing on config JSON object without caring for case sensitivity.

donttouch, donottouch, donttouchdb, donottouchdb,
donttouchdatabase, donottouchdatabase,
dontdelete, donotdelete, dontdeletedb, donotdeletedb,
dontdeletedatabase, donotdeletedatabase,
dont_touch, do_not_touch, dont_touch_db, do_not_touch_db,
dont_touch_database, do_not_touch_database,
dont_delete, do_not_delete, dont_delete_db, do_not_delete_db,
dont_delete_database, do_not_delete_database,
reserveddb, reserved_db

Example:

donttouch: ["production_db", "legacy_db"]

Separator Option

You can define a custom separator for internal operations:

Aliases: You can use these as key when declearing on config JSON object without caring for case sensitivity. sep, seperator

Example:

sep: "_"

Full Example Config File

{
  user: "root",
  password: "password123",
  host: "localhost",
  port: 3306,
  dropdb: true,
  droptable: true,
  dropcol: false,
  donttouch: ["production_db", "analytics_db"],
  sep: "_"
}

This configuration will:

  • Connect to MySQL using the given credentials
  • Drop databases and tables if they exist
  • Preserve "production_db" and "analytics_db"
  • Avoid dropping columns
  • Use _ as a separator internally

Installation

DBTASKER is available via npm.

Install it using either of the following commands:

npm install DBTASKER

or

npm i DBTASKER

Usage

DBTASKER is designed to be simple and declarative. You provide:

  1. A configuration object (database credentials + behavior options)

  2. A JSON schema object (database, tables, columns)

DBTASKER handles the rest.

Step 1: Import DBTASKER

Create a JavaScript file (for example: index.js) and import DBTASKER.

Using require (CommonJS)
const DBTASKER = require("DBTASKER");

Using import (ES Module)
import DBTASKER from "DBTASKER";

Step 2: Create a Configuration Object

This object defines how DBTASKER connects to the database and how it behaves.

const config = {
  host: "localhost",
  user: "root",
  password: "password",
  port: 3306
};

You can later extend this config with options like:

  • Drop database
  • Drop tables
  • Drop columns
  • Reserved / protected databases

Step 3: Define Your Schema JSON Object

Your schema is defined declaratively using a nested JSON structure:

const schema = {
  MyDatabase: {
    users: {
      id: {
        type: "int",
        autoincrement: true,
        primarykey: true
      },
      email: {
        type: "varchar",
        length: 255,
        required: true,
        unique: true
      },
      created_at: {
        type: "timestamp",
        defaults: "CURRENT_TIMESTAMP"
      }
    }
  }
};

DBTASKER supports multiple aliases for column keys and is case-insensitive.

Step 4: Run DBTASKER

Call DBTASKER by passing the config first, then the schema object.

DBTASKER(config, schema);

That’s it.

DBTASKER will:

  • Connect to MySQL
  • Validate your schema
  • Create or alter databases, tables, and columns
  • Apply indexes, foreign keys, defaults, and constraints

Full Minimal Example

const DBTASKER = require("DBTASKER");

const config = {
  host: "localhost",
  user: "root",
  password: "password",
  port: 3306,
  droptable: true,
  droptable: true,
  dropcolumn: true,
  donotdelete: ['test', 'example']
};

const schema = {
  app_db: {
    users: {
      id: {
        type: "int",
        primarykey: true,
        autoincrement: true
      },
      name: {
        type: "varchar",
        length: 100,
        required: true
      }
    }
  }
};

DBTASKER(config, schema);

Notes

Important:

  • The config object must always come first
  • The schema JSON object must come second
  • All keys are case-insensitive
  • Multiple aliases are supported for maximum flexibility

Column Key Aliases (Case-Insensitive)

DBTASKER allows multiple aliases for each column property. Keys are normalized internally.

Length / Size / Precision You can use these as key when declearing column property inside table object inside JSON object without caring for case sensitivity.

lengthvalue, length_value, size, scale, lengths,
length, value, values, range, maxlength, max_length, precision

Column Type / Data Type You can use these as key when declearing column property inside table object inside JSON object without caring for case sensitivity.

type, columntype, column_type,
datatype, data_type, typename, type_name

Zerofill You can use these as key when declearing column property inside table object inside JSON object without caring for case sensitivity.

zerofill, zero_fill, iszerofill, zerofillup

Auto Increment / Identity You can use these as key when declearing column property inside table object inside JSON object without caring for case sensitivity.

autoincrement, auto_increment, increment,
serial, generated, isidentity, identity

Signed / Unsigned You can use these as key when declearing column property inside table object inside JSON object without caring for case sensitivity.

signed, issigned, numericunsigned, numeric_unsigned,
unsigned, isunsigned

Defaults / Default Value You can use these as key when declearing column property inside table object inside JSON object without caring for case sensitivity.

default, defaults, defaultvalue, default_value,
example, sample, columndefault, column_default

Null / Not Null You can use these as key when declearing column property inside table object inside JSON object without caring for case sensitivity. Disallow NULL / Required

notnull, not_null, nonnullable, notnullable,
required, disallownull, non_nullable, not_nullable, disallow_null

Allow NULL / Optional

null, nulls, nullable, optional, isnulable, allownull, canbenull

Index / Key You can use these as key when declearing column property inside table object inside JSON object without caring for case sensitivity.

index, spatial, isspatial, fulltext, isfulltext,
isunique, isuniquekey, uniqueindex, uniquekey,
unique_index, unique_key,
primarykey, primary_key, primary, isprimary, isprimarykey,
indexkey, index_key, indexing

Comments / Description / Notes You can use these as key when declearing column property inside table object inside JSON object without caring for case sensitivity.

comment, comments, columncomment, column_comment,
description, label, helptext, hint, note

Foreign Key Definition Foreign keys are defined inline to reference another table’s column:

foreign_key: {
  table: "user",
  column: "id",
  delete: true,
  update: true
}

Foreign Key Aliases (Case-Insensitive)

DBTASKER accepts:

"fk", "foreign_key", "foreignkey"

Foreign Key Properties & Aliases Property

Alias Options

Purpose

Table

"table", "fktable", "fk_table", "foreignkeytable", "foreign_key_table"

Referenced table name

column

"column", "fkcolumn", "fk_column", "foreignkeycolumn", "foreign_key_column"

Referenced column name

delete

"delete", "ondelete", "on_delete", "when_Delete", "whenDelete", 'ifdelete', 'if_delete'

ON DELETE CASCADE behavior

update

"update", "onupdate", "on_update", "ifupdate", "if_update", "when_update", "whenupdate"

ON UPDATE CASCADE behavior

You can use value of delete and update option as: values

null, "NULL", "SET NULL", true, "DL", "DEL", "DELETE", "CASCADE", "DEFAULT", "SET DEFAULT", "RESTRICT", "NO ACTION"

Notes: DBTASKER automatically normalizes all keys internally.

Foreign key constraints are generated safely and include necessary values automatically.

Use Cases

Schema builders and migration tools

Admin dashboards

Low-code / no-code backends

License

MIT

Author

Md Nasiruddin Ahmed (Manik)

---Designed for safe, flexible, and high-quality MySQL schema automation.