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

@dbcube/schema-builder

v4.1.13

Published

The Dbcube Query Builder is a lightweight, flexible, and fluent library for building queries across multiple database engines, including MySQL, PostgreSQL, SQLite, and MongoDB, using JavaScript/Node.js. Its agnostic design allows you to generate data man

Readme

query-builder

The Dbcube Query Builder is a lightweight, flexible, and fluent library for building queries across multiple database engines, including MySQL, PostgreSQL, SQLite, and MongoDB, using JavaScript/Node.js.

Its agnostic design allows you to generate data manipulation (DML) and data definition (DDL) operations with a clean, chainable syntax—without sacrificing power or expressiveness.

It’s designed to work seamlessly in both SQL and NoSQL environments, providing a consistent abstraction layer across different storage technologies while still leveraging the native capabilities of each engine.

Features

  • Fluent API for building SQL queries
  • Type-safe query construction
  • Support for SELECT, INSERT, UPDATE, DELETE
  • Advanced WHERE conditions (AND, OR, groups, BETWEEN, IN, NULL checks)
  • JOINs: INNER, LEFT, RIGHT
  • Aggregations: COUNT, SUM, AVG, MAX, MIN
  • Ordering, Grouping, Distinct, Pagination
  • Column management (future extension)
  • Promise-based asynchronous API
  • Singleton connection management

Installation

npm install @dbcube/query-builder

Quick Start

import Database from "@dbcube/query-builder";

const db = new Database("my_database");

// Select all users
const users = await db.table("users").get();

// Select users with conditions
const activeUsers = await db
  .table("users")
  .where("status", "=", "active")
  .orderBy("created_at", "DESC")
  .limit(10)
  .get();

// Insert new users
await db
  .table("users")
  .insert([{ name: "John", email: "[email protected]", age: 30 }]);

// Update a user
await db.table("users").where("id", "=", 1).update({ status: "inactive" });

// Delete users
await db.table("users").where("status", "=", "deleted").delete();

API Documentation

Database

new Database(name: string)

Creates a new database connection instance.

table(tableName: string): Table

Returns a Table instance for building queries on the specified table.

Table

Query Methods

  • select(fields?: string[]): Specify columns to select.
  • where(column, operator, value): Add a WHERE condition.
  • orWhere(column, operator, value): Add an OR WHERE condition.
  • whereGroup(callback): Grouped WHERE conditions.
  • whereBetween(column, [min, max]): WHERE BETWEEN condition.
  • whereIn(column, values): WHERE IN condition.
  • whereNull(column): WHERE IS NULL condition.
  • whereNotNull(column): WHERE IS NOT NULL condition.
  • join(table, column1, operator, column2): INNER JOIN.
  • leftJoin(table, column1, operator, column2): LEFT JOIN.
  • rightJoin(table, column1, operator, column2): RIGHT JOIN.
  • orderBy(column, direction): ORDER BY clause.
  • groupBy(column): GROUP BY clause.
  • distinct(): DISTINCT clause.
  • count(column?): COUNT aggregation.
  • sum(column): SUM aggregation.
  • avg(column): AVG aggregation.
  • max(column): MAX aggregation.
  • min(column): MIN aggregation.
  • limit(number): LIMIT clause.
  • page(number): Pagination (requires limit).

Execution Methods

  • get(): Execute and return all matching rows.
  • first(): Execute and return the first matching row.
  • find(value, column?): Find a row by column value (default: id).
  • insert(data): Insert one or more rows.
  • update(data): Update rows matching the conditions.
  • delete(): Delete rows matching the conditions.

Example Usage

// Complex query with joins, grouping, and aggregation
const results = await db
  .table("orders")
  .join("users", "orders.user_id", "=", "users.id")
  .where("orders.status", "=", "completed")
  .groupBy("users.country")
  .sum("orders.total")
  .orderBy("sum", "DESC")
  .limit(5)
  .get();

Error Handling

All methods throw descriptive errors for invalid usage, such as missing WHERE conditions on update/delete, or invalid data types.

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

About

dbcube-query-builder is part of the dbcube ecosystem, designed to provide a robust and flexible query building experience for modern Node.js applications.