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

scorpdb

v1.0.5

Published

A powerful and modular Node.js database library for managing dynamic models, transactions, caching, RBAC, GraphQL, and more.

Downloads

4

Readme

ScorpDB

ScorpDB is a powerful, modular Node.js database library designed to handle complex database operations with ease. It comes with features such as dynamic model management, transaction handling, caching, RBAC (Role-Based Access Control), GraphQL integration, health checks, and much more. ScorpDB is perfect for developers looking to build scalable, secure, and maintainable applications.


Features

  • Dynamic Model System: Simplify database operations with reusable models.
  • Transaction Management: Ensure data consistency with robust transaction handling.
  • Caching: Improve performance with a Redis-based caching system.
  • RBAC: Implement secure, role-based access control.
  • GraphQL Integration: Query your database using GraphQL with ease.
  • Health Checks: Monitor system health with built-in database and cache status checks.
  • Query Profiling: Measure and optimize database query performance.
  • Event System: Emit and listen for system-wide events.
  • Localization: Support for multiple languages.
  • Backup and Restore: Easily back up and restore your database.
  • AI-Based Query Optimization: Optimize your SQL queries using AI.
  • Job Queue: Manage background tasks with a Bull-based job queue.
  • Rate Limiting: Protect APIs from overuse with request rate limiting.
  • Scheduler: Schedule recurring tasks using cron expressions.
  • Migration Management: Seamlessly manage database schema changes.

Installation

Install ScorpDB via npm:

npm install scorpdb
npm install scorpdb -g

Setup

Create a scorp.config.json file in your project root to define your database configuration:

// file: scorp.connect.json
{
  "database": {
    "host": "localhost",
    "port": 3306,
    "user": "root",
    "password": "your-password",
    "database": "your-database"
  }
}
  - scorp help           Display a list of available commands.
  - scorp install        Setup the ScorpDB module and configuration file.
  - scorp config view    Display the current database configuration.
  - scorp config reset   Reset the database configuration file.
  - scorp npm update     Update ScorpDB to the latest version.

Usage

Import the Library

const ScorpDB = require('scorpdb');

Database Connection

Connect to the database:

(async () => {
    try {
        await ScorpDB.Database.connect();
        console.log('Database connected!');
    } catch (error) {
        console.error('Connection error:', error.message);
    }
})();

Disconnect from the database:

await ScorpDB.Database.disconnect();

Dynamic Models

Define and use models for database operations:

const userModel = new ScorpDB.Model('users');

// Fetch all users
const users = await userModel.findAll();
console.log(users);

// Insert a new user
await userModel.insert({ name: 'John Doe', email: '[email protected]' });

// Update a user
await userModel.update(1, { name: 'John Smith' });

// Delete a user
await userModel.delete(1);

Transactions

Handle database transactions:

const transaction = ScorpDB.Transaction;

await transaction.start();
try {
    await ScorpDB.Database.query('INSERT INTO accounts (balance) VALUES (?)', [100]);
    await transaction.commit();
    console.log('Transaction committed.');
} catch (error) {
    await transaction.rollback();
    console.error('Transaction rolled back:', error.message);
}

Caching

Use Redis for caching:

await ScorpDB.Cache.set('key', 'value');
const value = await ScorpDB.Cache.get('key');
console.log('Cached value:', value);

RBAC (Role-Based Access Control)

Define roles and permissions:

ScorpDB.RBAC.addRole('admin', ['create', 'read', 'update', 'delete']);
const access = ScorpDB.RBAC.hasAccess('admin', 'create');
console.log('Admin access to create:', access);

GraphQL Integration

Query your database using GraphQL:

const query = `
    {
        hello
    }
`;
const result = await ScorpDB.GraphQL.executeQuery(query);
console.log(result);

Health Checks

Monitor the health of the database and caching systems:

const status = await ScorpDB.HealthCheck.getStatus();
console.log('System Health:', status);

Scheduler

Schedule recurring tasks:

ScorpDB.Scheduler.schedule('taskName', '0 3 * * *', () => {
    console.log('Task executed at 3 AM!');
});

Backup and Restore

Back up and restore your database:

ScorpDB.Backup.backup('backup.sql');
ScorpDB.Backup.restore('backup.sql');

AI-Based Query Optimization

Optimize your SQL queries using AI:

const originalQuery = 'SELECT * FROM users WHERE email LIKE "%@example.com"';
const optimizedQuery = await ScorpDB.AIOptimizer.optimizeQuery(originalQuery);
console.log('Optimized Query:', optimizedQuery);

Job Queue

Manage background tasks:

const emailQueue = new ScorpDB.JobQueue('emailQueue');

emailQueue.addJob({ email: '[email protected]', message: 'Hello!' });

emailQueue.process(5, async (job) => {
    console.log(`Sending email to ${job.data.email}`);
});

Migration Management

Apply or rollback migrations:

await ScorpDB.Migrations.runMigrations(); // Apply all migrations
await ScorpDB.Migrations.rollbackMigration('001_create_users_table.js'); // Rollback a specific migration

Contribution

We welcome contributions to improve ScorpDB. Please feel free to open issues or submit pull requests.


License

ScorpDB is open-source software licensed under the MIT License.