{"id":42774,"library":"fragments-postgres","title":"fragments-postgres","description":"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.","status":"active","version":"1.0.0-beta.11","language":"javascript","source_language":"en","source_url":"git://github.com/snd/fragments-postgres","tags":["javascript","fragments","postgres","migrate","migration"],"install":[{"cmd":"npm install fragments-postgres","lang":"bash","label":"npm"},{"cmd":"yarn add fragments-postgres","lang":"bash","label":"yarn"},{"cmd":"pnpm add fragments-postgres","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core framework that provides the application structure and command system.","package":"fragments","optional":false},{"reason":"Database query builder used for auto-generated tables and accessor functions.","package":"mesa","optional":false},{"reason":"Dependency injection library used to compose the application source.","package":"hinoki","optional":false}],"imports":[{"note":"Default import is the typical pattern; CommonJS require also works as the package is not ESM-only.","wrong":"var fragmentsPostgres = require('fragments-postgres')","symbol":"fragmentsPostgres","correct":"import fragmentsPostgres from 'fragments-postgres'"},{"note":"The mesa key is exposed via the dependency injection source; it is not directly exported as a named export from the module.","wrong":"","symbol":"mesa","correct":"import { mesa } from 'fragments-postgres'"},{"note":"Auto-generated table objects are accessible via the source's dependency injection, not direct exports.","wrong":"const userTable = require('fragments-postgres').userTable","symbol":"userTable","correct":"import { userTable } from 'fragments-postgres'"}],"quickstart":{"code":"import hinoki from 'hinoki';\nimport fragments from 'fragments';\nimport fragmentsPostgres from 'fragments-postgres';\n\nconst source = hinoki.source([\n  __dirname,\n  fragments.source,\n  fragmentsPostgres\n]);\n\nconst app = fragments(source);\n\napp.runCommand();","lang":"javascript","description":"Shows how to add fragments-postgres as a source to a fragments application, enabling migration commands and auto-generated database accessor functions."},"warnings":[{"fix":"Pin to a specific version and test thoroughly before upgrading.","message":"The 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.","severity":"breaking","affected_versions":">=1.0.0-beta.0 <1.0.0"},{"fix":"Refer to the source code or issue tracker for actual behavior.","message":"The documentation states that the readme is unfinished, implying some features may be missing or inaccurate.","severity":"deprecated","affected_versions":"all"},{"fix":"Ensure all required environment variables are defined before starting the application.","message":"Environment variables (DATABASE_URL, POSTGRES_POOL_SIZE, MIGRATION_PATH, POSTGRES_DATABASE) must be set for most functionality to work. Missing variables will cause runtime errors.","severity":"gotcha","affected_versions":"all"},{"fix":"Double-check table and column names match exactly; use the generated table objects (e.g., `userTable`) for explicit queries.","message":"Auto-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.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure the source is constructed exactly as shown in the quickstart, including `hinoki.decorateSourceToAlsoLookupWithPrefix` if needed.","message":"The package relies on the 'hinoki' dependency injection library. If not configured correctly, certain keys may not be available.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'accessor':22,45 'applic':10 'auto':16 'auto-gener':15 'automat':39 'base':47 'beta':28 'builder':67 'cadenc':74 'command':14 'coupl':59 'creat':40 'crud':44 'current':26 'data':21 'databas':36,55 'develop':82 'differ':52 'document':32 'environ':49 'fragment':2,9,62,84 'fragments-postgr':1 'framework':11,63 'function':23,46 'generat':17 'integr':6 'irregular':76 'javascript':83 'limit':70 'manag':37 'may':69 'mesa':18,65 'migrat':13,86,87 'object':42 'packag':34 'postgr':3,85 'postgresql':5 'provid':12 'queri':66 'releas':73 'simplifi':35 'standalon':71 'still':80 'tabl':19,41 'tight':58 'tool':56 'unfinish':31 'use':72 'v1.0.0-beta.11':29 'variabl':50","created_at":"2026-06-05T16:56:36.684633+00:00","updated_at":"2026-06-05T16:56:36.684633+00:00","problems":[{"fix":"npm install hinoki","cause":"The 'hinoki' package is a peer dependency but not installed.","error":"Error: Cannot find module 'hinoki'"},{"fix":"export DATABASE_URL=postgres://user:pass@localhost:5432/mydb","cause":"The application requires DATABASE_URL to be defined in the environment.","error":"Error: Environment variable DATABASE_URL is not set"},{"fix":"Add 'mesa' to the hinoki source array: hinoki.source([..., 'mesa', ...])","cause":"The 'mesa' package is not included in the fragments source.","error":"Error: Mesa is not found. Ensure 'mesa' is provided as a source."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"http://github.com/snd/fragments-postgres","github":"git://github.com/snd/fragments-postgres","docs":null,"changelog":null,"pypi":null,"npm":"fragments-postgres","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}