用于 Cloudflare 工作者的零依赖查询构建器
Zero-dependency Query Builder for Cloudflare Workers
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.
workers-qb provides AI coding assistant skills to help you write queries faster. Install them using npx skills:
npx skills install G4brym/workers-qbAvailable skills:
npm install workers-qb --save…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
}
}First, install the required PostgreSQL client:
npm install pg --saveEnable Node compatibility in wrangler.toml:
node_compat = trueExample usage:
…Visit our comprehensive documentation for detailed information about:
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
暂无开放 Issues,或尚未同步最近议题。