Registry / database / sedk-postgres

sedk-postgres

JSON →
library0.15.1jsnpmunverified

A type-safe SQL builder and validator for PostgreSQL, currently at version 0.15.1 with a development-level release cadence. Key differentiators include compile-time SQL validation (catching syntax errors before execution), automatic parameterization to prevent SQL injection, and a fluent builder API. Compared to knex or sql-builder, sedk-postgres provides stronger type guarantees via TypeScript and explicit schema definition.

npm install sedk-postgres
INSTALL
IMPORT
SIG · SEDK-POSTGRES
S
sedk-postgres
databasejavascriptv0.15.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

defineTable
import { defineTable } from 'sedk-postgres'
import { defineTable } from 'sedk-postgres/lib/defineTable'
Main entry for table definition; ESM only.
SQL
import { SQL } from 'sedk-postgres'
import SQL from 'sedk-postgres'
Named export, not default.
select
import { select } from 'sedk-postgres'
Builder function for SELECT queries.

Defines a table and builds a SELECT query with parameterized WHERE clause, outputting SQL text and values.

import { defineTable, select, SQL } from 'sedk-postgres'; const users = defineTable('users', { id: { type: 'INTEGER', primaryKey: true }, name: { type: 'TEXT' }, email: { type: 'TEXT' }, }); const query = select(users.id, users.name) .from(users) .where(users.email.like('%@example.com')) .toSQL(); console.log(query); // Output: { text: 'SELECT users.id, users.name FROM users WHERE users.email LIKE $1', values: ['%@example.com'] }
Debug
Known issues
breakingVersion 0.14 renamed `defineTable`'s `type` property from `'string'` to `'TEXT'` and `'number'` to `'INTEGER'`.
fix
Update column types to uppercase PG types: `'TEXT'`, `'INTEGER'`, etc.
affects: >=0.14
breakingIn v0.13, the `toSQL()` method changed output format from a string to `{ text: string, values: any[] }`.
fix
Adapt code to destructure `text` and `values` from the result.
affects: >=0.13
deprecatedThe default import `import sedk from 'sedk-postgres'` is deprecated as of v0.15.
fix
Use named imports like `import { select } from 'sedk-postgres'`.
affects: >=0.15
gotchaColumn names in `defineTable` are case-sensitive; PostgreSQL unquoted identifiers become lowercase.
fix
Define columns in lowercase to match PostgreSQL behavior, or quote identifiers manually.
affects: >=0.1
gotchaUsing `.toSQL()` multiple times on the same builder instance may produce unexpected results because the builder mutates state.
fix
Clone the builder or rebuild before each `.toSQL()` call.
affects: >=0.1
Errors
Common errors & fixes
TypeError: defineTable is not a function
Using default import instead of named import.
fix
Change to `import { defineTable } from 'sedk-postgres'`.
Error: Unsupported column type 'string'
Using old type names from v0.13 or earlier.
fix
Update types to uppercase PostgreSQL types: `'TEXT'`, `'INTEGER'`, etc.
Query result is a string instead of an object
Using older version that returns raw SQL string from .toSQL().
fix
Upgrade to v0.13+ and destructure `{ text, values }` from the result.
Cannot find module 'sedk-postgres'
Package not installed or not in node_modules.
fix
Run `npm install sedk-postgres` and ensure import path is correct.
Upgrade
Version history
0.15.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
12
Meta
2
Amazon
1
Resources
sedk-postgres — npm install sedk-postgres · libregistry