
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
@dbcube/schema-builder
Advanced tools
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
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.
npm install @dbcube/query-builder
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: "john@example.com", 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();
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.
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).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.// 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();
All methods throw descriptive errors for invalid usage, such as missing WHERE conditions on update/delete, or invalid data types.
This project is licensed under the MIT License.
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
dbcube-query-builder is part of the dbcube ecosystem, designed to provide a robust and flexible query building experience for modern Node.js applications.
FAQs
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
The npm package @dbcube/schema-builder receives a total of 2,757 weekly downloads. As such, @dbcube/schema-builder popularity was classified as popular.
We found that @dbcube/schema-builder demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.