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 🙏

© 2026 – Pkg Stats / Ryan Hefner

cwk-db

v1.0.9

Published

Advanced database system with multi-database support, caching, encryption, and schema validation.

Readme

🚀 CWK DB

An advanced and easy-to-use database system for Node.js with multi-database support, caching, encryption, and schema validation.


🌟 Features

  • Multi-Database Support: SQLite and Redis
  • Advanced Querying: Filtering, sorting, and pagination
  • 🧩 Schema Validation: Ensure structured data
  • 🚀 Caching System: Faster reads with configurable cache
  • 🔒 Encryption: Secure sensitive data
  • 🧹 Simple API: Minimal and user-friendly design
  • 💾 Transactions: Atomic operations
  • 🔗 Plugin System: Extend functionality

📦 Installation

npm install cwk-db

💡 Usage

🔗 Connecting to a Database

const db = require('cwk-db');

// Connect to SQLite
await db.connect('sqlite://database.sqlite');

// Connect to Redis
await db.connect('redis://localhost:6379');

// Check database connection
await db.ping();

CRUD Operations

// Create or update data
await db.set('user:123', { name: 'John', age: 30 });

// Get data
const user = await db.get('user:123');
console.log(user);

// Delete data
await db.delete('user:123');

// Check if a key exists
const exists = await db.has('user:123');
console.log(exists);

📋 Advanced Querying

// Filtering
const users = await db.query('users').filter({ age: { $gt: 25 } }).get();

// Sorting
const sortedUsers = await db.query('users').sort('age', 'desc').get();

// Pagination
const page1 = await db.query('users').paginate(1, 10).get();

// Complex queries with multiple conditions
const advancedQuery = await db.query('users').filter({
  age: { $gt: 25 },
  name: { $regex: '^J' }
}).sort('name', 'asc').paginate(1, 5).get();

Caching

// Enable caching
await db.enableCache({ duration: 60, maxSize: 100 }); // Cache duration in seconds, max cache size

// Clear cache
await db.clearCache();

// Check cache status
console.log(db.cacheStatus());

🔒 Encryption

// Enable encryption
await db.enableEncryption('my_secret_key', { algorithm: 'aes-256-cbc' });

// Data will be encrypted automatically
await db.set('sensitiveData', 'This is confidential');

// Retrieve and decrypt data
const sensitiveData = await db.get('sensitiveData');
console.log(sensitiveData);

🛠️ Configuration

You can configure the database using environment variables or programmatically.

| 📝 Option | 📋 Description | |--------------------|--------------------------------------------------| | DB_URL | Database connection URL | | CACHE_DURATION | Cache duration in seconds | | CACHE_MAX_SIZE | Maximum number of items in the cache | | ENCRYPTION_KEY | Secret key for encryption | | ENCRYPTION_ALGO | Encryption algorithm (default: aes-256-cbc) |


🔗 Plugins

Extend the functionality using plugins:

const myPlugin = (db) => {
  db.customMethod = () => console.log('Custom method');
};

db.use(myPlugin);
db.customMethod();

// List all registered plugins
console.log(db.listPlugins());

⚠️ Error Handling

try {
  await db.set('user:123', { name: 'John' });
} catch (error) {
  console.error('Database error:', error.message);
}

// Custom error handling
await db.onError((error) => {
  console.error('Custom error handler:', error);
});

🧪 Testing

npm test

// Run tests with coverage
npm run coverage

📄 Documentation


🤝 Contributing

Contributions are welcome! Feel free to submit a pull request or open an issue.

  1. Fork the repository
  2. Create a new branch (git checkout -b feature-branch)
  3. Commit your changes (git commit -m 'Add new feature')
  4. Push to the branch (git push origin feature-branch)
  5. Submit a Pull Request

📜 License

This project is licensed under the MIT License.