{"id":43659,"library":"postgres-entities","title":"postgres-entities","description":"A library for storing structured JSON documents with versioning, etag/last-modified tracking, and zero-downtime migration support in PostgreSQL. Current stable version is 1.1.3, under initial development. Designed as a replacement for Azure Entities, it targets Node.js >=10 and focuses on redeployability, data visibility, and reliable optimistic concurrency via automatic etag and last-modified columns. Key differentiators include a human-readable storage format, table-level stored procedures for atomic updates, and built-in migration flow supporting multiple schema versions.","status":"active","version":"1.1.3","language":"javascript","source_language":"en","source_url":"github.com:jhford/postgres-entities","tags":["javascript"],"install":[{"cmd":"npm install postgres-entities","lang":"bash","label":"npm"},{"cmd":"yarn add postgres-entities","lang":"bash","label":"yarn"},{"cmd":"pnpm add postgres-entities","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"PostgreSQL client for database connections","package":"pg","optional":false}],"imports":[{"note":"The library is ESM-only; using require() will fail.","wrong":"const { Entity } = require('postgres-entities')","symbol":"Entity","correct":"import { Entity } from 'postgres-entities'"},{"note":"defineEntity is a named export, not default.","wrong":"import defineEntity from 'postgres-entities'","symbol":"defineEntity","correct":"import { defineEntity } from 'postgres-entities'"},{"note":"TypeScript users should import the type for schema definitions.","wrong":null,"symbol":"EntitySchema","correct":"import type { EntitySchema } from 'postgres-entities'"}],"quickstart":{"code":"import { defineEntity } from 'postgres-entities';\nimport { Pool } from 'pg';\n\nconst pool = new Pool({\n  connectionString: process.env.DATABASE_URL ?? 'postgres://localhost/mydb',\n});\n\nconst MyEntity = defineEntity({\n  tableName: 'my_entities',\n  version: 1,\n  properties: {\n    id: { type: 'string', partitionKey: true },\n    name: { type: 'string' },\n    count: { type: 'number' },\n  },\n});\n\nasync function main() {\n  await MyEntity.ensureTable(pool);\n  const entity = await MyEntity.create(pool, {\n    id: 'abc',\n    name: 'test',\n    count: 42,\n  });\n  console.log('Created:', entity);\n}\n\nmain().catch(console.error);","lang":"typescript","description":"Shows how to define an entity schema, ensure the table exists, and create an entity."},"warnings":[{"fix":"Upgrade Node.js to version 10 or later.","message":"Requires Node.js >=10.0.0; older versions will fail to run.","severity":"breaking","affected_versions":"<10.0.0"},{"fix":"Use lowercase table names in defineEntity.","message":"Table names are case-sensitive in PostgreSQL; mismatched casing causes errors.","severity":"breaking","affected_versions":"all"},{"fix":"Do not directly update etag or last_modified columns; use library methods.","message":"ETag and last-modified columns are auto-managed; manual updates may break concurrency.","severity":"gotcha","affected_versions":"all"},{"fix":"Always include a version property in the entity definition.","message":"Entity schema versioning is required; missing version field will throw.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Define a migration function when bumping the version.","message":"Migration functions must be provided for version upgrades; otherwise old entities become unreadable.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'1.1.3':27 '10':41 'atom':75 'automat':53 'azur':36 'built':79 'built-in':78 'column':59 'concurr':51 'current':23 'data':46 'design':31 'develop':30 'differenti':61 'document':10 'downtim':18 'entiti':3,37 'etag':54 'etag/last-modified':13 'flow':82 'focus':43 'format':68 'human':65 'human-read':64 'includ':62 'initi':29 'javascript':87 'json':9 'key':60 'last':57 'last-modifi':56 'level':71 'librari':5 'migrat':19,81 'modifi':58 'multipl':84 'node.js':40 'optimist':50 'postgr':2 'postgres-ent':1 'postgresql':22 'procedur':73 'readabl':66 'redeploy':45 'reliabl':49 'replac':34 'schema':85 'stabl':24 'storag':67 'store':7,72 'structur':8 'support':20,83 'tabl':70 'table-level':69 'target':39 'track':14 'updat':76 'version':12,25,86 'via':52 'visibl':47 'zero':17 'zero-downtim':16","created_at":"2026-06-05T17:00:52.103151+00:00","updated_at":"2026-06-05T17:00:52.103151+00:00","problems":[{"fix":"Run `npm install postgres-entities` from the project root.","cause":"Package not installed or not resolved in current module context.","error":"Error: Cannot find module 'postgres-entities'"},{"fix":"Use `import { defineEntity } from 'postgres-entities'`.","cause":"Incorrect import style (default vs named).","error":"TypeError: defineEntity is not a function"},{"fix":"Call `await MyEntity.ensureTable(pool)` before CRUD operations.","cause":"Table not created before use.","error":"error: relation \"my_entities\" does not exist"}],"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":"github.com:jhford/postgres-entities","github":"github.com:jhford/postgres-entities","docs":null,"changelog":null,"pypi":null,"npm":"postgres-entities","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}}