Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
W

workers-qb

> 编程语言
Open source

Zero dependencies Query Builder for Cloudflare Workers

398 stars0 likes0 views
WebsiteGitHub

About

Zero dependencies Query Builder for Cloudflare Workers

Zero-dependency Query Builder for Cloudflare Workers

Overview

workers-qb is a lightweight query builder designed specifically for Cloudflare Workers. It provides a simple, standardized interface while maintaining the performance benefits of raw queries over traditional ORMs.

Read the full documentation

Key Differences from ORMs

  • Focused on direct SQL access with convenient wrapper methods
  • Maintains raw query performance
  • Zero dependencies
  • Lightweight and Worker-optimized

AI Skills

workers-qb provides AI coding assistant skills to help you write queries faster. Install them using npx skills:

bash
npx skills install G4brym/workers-qb

Available skills:

  • write-sql-queries - Comprehensive guide for writing SELECT, INSERT, UPDATE, DELETE queries

Supported Databases

  • ☁️ Cloudflare D1
  • Cloudflare Durable Objects
  • PostgreSQL (via node-postgres)
  • Bring Your Own Database

Features

Core Features

  • Zero dependencies
  • Full TypeScript support
  • Schema-aware type inference with autocomplete
  • Database schema migrations
  • Lazy row loading

Query Operations

  • Table operations (create/drop)
  • CRUD operations (insert/update/select/delete)
  • Bulk inserts
  • JOIN queries
  • Subqueries
  • Modular SELECT queries
  • ON CONFLICT handling
  • UPSERT support

Installation

bash
npm install workers-qb --save

Usage Examples

Cloudflare D1

…

Cloudflare Durable Objects

typescript
import { DOQB } from 'workers-qb'

type Schema = {
  employees: {
    id: number
    name: string
    role: string
  }
}

export class MyDurableObject extends DurableObject {
  #qb: DOQB

  constructor(ctx: DurableObjectState, env: Env) {
    super(ctx, env)
    this.#qb = new DOQB(ctx.storage.sql)
  }

  getEmployees() {
    // DOQB operations are synchronous - no await needed!
    return this.#qb
      .fetchAll({
        tableName: 'employees',  // ✓ Autocomplete
      })
      .execute()
      .results
  }
}

PostgreSQL Integration

First, install the required PostgreSQL client:

bash
npm install pg --save

Enable Node compatibility in wrangler.toml:

toml
node_compat = true

Example usage:

…

Documentation

Visit our comprehensive documentation for detailed information about:

  • Basic Queries
  • Advanced Queries
  • Migrations
  • Type Checking
  • Database-specific guides

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Issues· 2 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScriptcloudflarecloudflare-d1cloudflare-workersd1sql

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言