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

tomsdb

v1.0.1

Published

Node.js client for tomsdb database server

Readme

tomsdb

Node.js client for tomsdb database server.

Install

npm install tomsdb

Quick Start

const tomsdb = require('tomsdb');

const db = await tomsdb.createConnection({
  host: 'localhost',
  port: 5432,
  user: 'admin',
  password: 'admin123',
  database: 'myapp'
});

await db.query('CREATE TABLE users (id INT AUTO_INCREMENT, name STRING REQUIRED, age INT)');
await db.query('INSERT INTO users (name, age) VALUES ("Alice", 25)');

const result = await db.query('SELECT * FROM users');
console.log(result);

db.end();

API

tomsdb.createConnection(options)Promise<Connection>

Creates and returns a connected, authenticated connection.

const db = await tomsdb.createConnection({
  host: 'localhost',       // default: 'localhost'
  port: 5432,              // default: 5432
  user: 'admin',           // default: 'admin'
  password: 'admin123',    // default: 'admin123'
  database: 'myapp',       // optional, auto-runs USE <database>
  connectTimeout: 10000,   // ms, default: 10000
  queryTimeout: 30000      // ms, default: 30000
});

connection.query(sql)Promise<string|object[]>

Execute a SQL statement.

await db.query('CREATE DATABASE shop');
await db.query('USE shop');
await db.query('CREATE TABLE products (id INT AUTO_INCREMENT, name STRING REQUIRED, price INT)');
await db.query('INSERT INTO products (name, price) VALUES ("Widget", 999)');

const rows = await db.query('SELECT * FROM products');
console.log(rows);

connection.ping()Promise<void>

Check if the server is reachable.

await db.ping(); // throws on failure

connection.end()

Gracefully close the connection.

connection.destroy()

Forcefully close the connection.


tomsdb.createPool(options)Pool

Create a connection pool for concurrent usage.

const pool = tomsdb.createPool({
  host: 'localhost',
  port: 5432,
  user: 'admin',
  password: 'admin123',
  database: 'myapp',
  connectionLimit: 10,  // default: 10
  queueLimit: 0         // 0 = unlimited, default: 0
});

pool.query(sql)Promise<string|object[]>

Auto-acquires a connection, runs the query, and releases it back.

const result = await pool.query('SELECT * FROM users');

pool.getConnection()Promise<PoolConnection>

Manually acquire a connection (useful for transactions).

const conn = await pool.getConnection();

await conn.query('BEGIN TRANSACTION');
await conn.query('INSERT INTO orders (product, qty) VALUES ("Widget", 2)');
await conn.query('UPDATE inventory SET stock = stock - 2 WHERE product = "Widget"');
await conn.query('COMMIT');

conn.release(); // return to pool

pool.end()Promise<void>

Close all connections in the pool.

Response Formatting

The SDK automatically formats human-readable string responses from the server into structured JavaScript objects.

| Command | Formatted Output | |---------|------------------| | SELECT * ... | [{ id: '1', name: 'Alice' }, ...] | | SHOW DATABASES | [{ name: 'watchup', current: true }, ...] | | SHOW TABLES | ['users', 'posts'] | | DESCRIBE table | { table: 'users', schema: [...] } |

To disable formatting and get raw strings, set raw: true in your options:

const db = await tomsdb.createConnection({ ..., raw: true });

Express Example

const express = require('express');
const tomsdb = require('tomsdb');

const app = express();
const pool = tomsdb.createPool({
  host: process.env.DB_HOST || 'localhost',
  port: parseInt(process.env.DB_PORT) || 5432,
  user: process.env.DB_USER || 'admin',
  password: process.env.DB_PASS || 'admin123',
  database: 'myapp',
  connectionLimit: 20
});

app.get('/users', async (req, res) => {
  try {
    const result = await pool.query('SELECT * FROM users');
    res.json({ data: result });
  } catch (err) {
    res.status(500).json({ error: err.message });
  }
});

app.listen(3000, () => console.log('Server running on :3000'));

License

MIT