Registry / database / fragments-postgres

fragments-postgres

JSON →
library1.0.0-beta.11jsnpmunverified

A PostgreSQL integration for the fragments application framework, providing migration commands, auto-generated Mesa tables, and data accessor functions. It is currently in beta (v1.0.0-beta.11) with unfinished documentation. The package simplifies database management by automatically creating table objects and CRUD accessor functions based on environment variables. It differs from other database tools by tightly coupling with the fragments framework and Mesa query builder, which may limit standalone use. Release cadence is irregular as it is still in development.

npm install fragments-postgres
INSTALL
IMPORT
SIG · FRAGMENTS-POSTGRES
F
fragments-postgres
databasejavascriptv1.0.0-beta.11
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.

fragmentsPostgres
import fragmentsPostgres from 'fragments-postgres'
var fragmentsPostgres = require('fragments-postgres')
Default import is the typical pattern; CommonJS require also works as the package is not ESM-only.
mesa
import { mesa } from 'fragments-postgres'
The mesa key is exposed via the dependency injection source; it is not directly exported as a named export from the module.
userTable
import { userTable } from 'fragments-postgres'
const userTable = require('fragments-postgres').userTable
Auto-generated table objects are accessible via the source's dependency injection, not direct exports.

Shows how to add fragments-postgres as a source to a fragments application, enabling migration commands and auto-generated database accessor functions.

import hinoki from 'hinoki'; import fragments from 'fragments'; import fragmentsPostgres from 'fragments-postgres'; const source = hinoki.source([ __dirname, fragments.source, fragmentsPostgres ]); const app = fragments(source); app.runCommand();
Debug
Known issues
breakingThe package is in beta (v1.0.0-beta.11) and the API is subject to change without major version bumps. Use with caution in production.
fix
Pin to a specific version and test thoroughly before upgrading.
affects: >=1.0.0-beta.0 <1.0.0
deprecatedThe documentation states that the readme is unfinished, implying some features may be missing or inaccurate.
fix
Refer to the source code or issue tracker for actual behavior.
affects: all
gotchaEnvironment variables (DATABASE_URL, POSTGRES_POOL_SIZE, MIGRATION_PATH, POSTGRES_DATABASE) must be set for most functionality to work. Missing variables will cause runtime errors.
fix
Ensure all required environment variables are defined before starting the application.
affects: all
gotchaAuto-generated accessor functions require table names and column names to be used as function names (e.g., `firstUserWhereId(id)`). Typos will silently resolve to undefined functions.
fix
Double-check table and column names match exactly; use the generated table objects (e.g., `userTable`) for explicit queries.
affects: all
gotchaThe package relies on the 'hinoki' dependency injection library. If not configured correctly, certain keys may not be available.
fix
Ensure the source is constructed exactly as shown in the quickstart, including `hinoki.decorateSourceToAlsoLookupWithPrefix` if needed.
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'hinoki'
The 'hinoki' package is a peer dependency but not installed.
fix
npm install hinoki
Error: Environment variable DATABASE_URL is not set
The application requires DATABASE_URL to be defined in the environment.
fix
export DATABASE_URL=postgres://user:pass@localhost:5432/mydb
Error: Mesa is not found. Ensure 'mesa' is provided as a source.
The 'mesa' package is not included in the fragments source.
fix
Add 'mesa' to the hinoki source array: hinoki.source([..., 'mesa', ...])
Upgrade
Version history
1.0.0-beta.11latest on npm
Audit
Dependencies
fragmentsrequiredCore framework that provides the application structure and command system.
mesarequiredDatabase query builder used for auto-generated tables and accessor functions.
hinokirequiredDependency injection library used to compose the application source.
Agent activity
8 hits · last 30 days
node
8
Resources
fragments-postgres — npm install fragments-postgres · libregistry