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.fixPin 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.fixRefer 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.fixEnsure 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.fixDouble-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.fixEnsure 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.
Error: Environment variable DATABASE_URL is not set
The application requires DATABASE_URL to be defined in the environment.
fixexport 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.
fixAdd '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.