Skip to content

faasjs/typed-pg

Repository files navigation

typed-pg

License: MIT NPM Version Last commit Unit Status

Coverage Status Commits Downloads Pull requests

This package is still in development and not yet ready for production use.

A type-safe PostgreSQL query builder for TypeScript with a fluent API.

Features

  • 🎯 Full TypeScript support
  • 🔒 Type-safe queries
  • ⚡ Built on top of the high-performance postgres.js package
  • 🔗 Fluent chainable API
  • 🧩 Flexible SQL fragments: whereRaw, orWhereRaw, orderByRaw
  • 🔍 Pattern matching operators in where: LIKE, ILIKE, NOT LIKE, NOT ILIKE
  • 🔀 Join helpers: join and leftJoin with Knex-style arguments
  • 🛡️ SQL injection prevention
  • 📦 Transaction support
  • 🎨 Clean and intuitive API

Query examples

await client
  .query('users')
  .join('profiles', 'users.id', 'profiles.user_id')
  .where('users.name', 'ILIKE', 'alice%')
  .whereRaw('"profiles"."deleted_at" IS NULL')
  .orWhereRaw('"users"."is_admin" = ?', true)
  .orderByRaw('CASE WHEN "users"."status" = ? THEN 0 ELSE 1 END', 'active')

Installation

npm install typed-pg

Testing

Tests run against a PGlite socket server started by Vitest global setup, so no external PostgreSQL service is required.

About

A type-safe PostgreSQL query builder for TypeScript with a fluent API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages