{"id":42538,"library":"consequent-postgres","title":"Consequent Postgres","description":"PostgreSQL storage adapters for the Consequent event sourcing framework. Current version is 2.0.3 (ESM-only, requires Node >=18, PostgreSQL >=12). Provides actor (snapshot), event, and search storage implementations backed by PostgreSQL, with TypeScript type declarations included. Key differentiators: designed specifically for Consequent's event sourcing model, supports JSONB-based queries, ID mapping between system and aggregate IDs, and does not support siblings (optimized for microservice architectures).","status":"active","version":"2.0.3","language":"javascript","source_language":"en","source_url":"git://github.com/arobson/consequent-postgres","tags":["javascript","postgres","consequent","event-sourcing","typescript","esm"],"install":[{"cmd":"npm install consequent-postgres","lang":"bash","label":"npm"},{"cmd":"yarn add consequent-postgres","lang":"bash","label":"yarn"},{"cmd":"pnpm add consequent-postgres","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only; CommonJS require is not supported.","wrong":"const { initialize } = require('consequent-postgres')","symbol":"initialize","correct":"import { initialize } from 'consequent-postgres'"},{"note":"This is a TypeScript type, not a runtime value. Use 'import type' for types to avoid errors.","wrong":"import { ConsequentPostgres } from 'consequent-postgres'","symbol":"ConsequentPostgres","correct":"import type { ConsequentPostgres } from 'consequent-postgres'"},{"note":"Actor and Event are TypeScript types/interfaces, not constructors.","wrong":"import { Actor } from 'consequent-postgres'","symbol":"Actor","correct":"import type { Actor, Event } from 'consequent-postgres'"}],"quickstart":{"code":"import { initialize } from 'consequent-postgres';\n\nconst adapter = initialize({\n  connectionString: process.env.DATABASE_URL ?? 'postgresql://user:password@localhost:5432/mydb'\n});\n\nconst actors = await adapter.actor.create('user');\nawait actors.store('user-123', 'a:1', {\n  id: 'user-123',\n  name: 'John Doe',\n  email: 'john@example.com',\n  lastEventId: 'evt-456',\n  lastCommandId: 'cmd-789',\n  lastCommandHandledOn: new Date().toISOString(),\n  lastEventAppliedOn: new Date().toISOString()\n});\nconst actor = await actors.fetch('user-123');\nawait adapter.close();","lang":"typescript","description":"Demonstrates initializing the PostgreSQL adapter, creating an actor store, storing and retrieving an actor snapshot, and closing the connection."},"warnings":[{"fix":"Use import syntax and ensure your project is configured for ESM (e.g., type: module in package.json or .mjs extension).","message":"Version 2.0.0+ is ESM-only; requires Node >=18 and cannot be used with CommonJS require().","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use const adapter = await initialize(config);","message":"initialize() no longer accepts a callback; returns a promise. You must await it.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use `fetchByLastEventId` with the appropriate event ID instead.","message":"The method `fetchByLastEventDate` is deprecated and may be removed in a future version.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Ensure your domain model does not require siblings; route writes by aggregate ID consistently.","message":"The adapter does not support siblings (multiple actor records per aggregate). Designed for microservice architectures where services own their database.","severity":"gotcha","affected_versions":"*"},{"fix":"Always include a vector string that matches the expected format (e.g., incrementing a version counter).","message":"The event store's `storeEvents` expects an array of events with a `vector` property as a string (e.g., 'a:1'). The vector must be provided; it is not auto-generated.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'12':23 '18':21 '2.0.3':15 'actor':25 'adapt':5 'aggreg':60 'architectur':70 'back':32 'base':53 'consequ':1,8,45,73 'current':12 'declar':38 'design':42 'differenti':41 'esm':17,78 'esm-on':16 'event':9,27,47,75 'event-sourc':74 'framework':11 'id':55,61 'implement':31 'includ':39 'javascript':71 'jsonb':52 'jsonb-bas':51 'key':40 'map':56 'microservic':69 'model':49 'node':20 'optim':67 'postgr':2,72 'postgresql':3,22,34 'provid':24 'queri':54 'requir':19 'search':29 'sibl':66 'snapshot':26 'sourc':10,48,76 'specif':43 'storag':4,30 'support':50,65 'system':58 'type':37 'typescript':36,77 'version':13","created_at":"2026-06-05T16:55:28.320260+00:00","updated_at":"2026-06-05T16:55:28.320260+00:00","problems":[{"fix":"Add \"type\": \"module\" to your package.json or rename file to .mjs.","cause":"ESM-only package used in a CommonJS project without ESM configuration.","error":"TypeError: Cannot use import statement outside a module"},{"fix":"Ensure PostgreSQL is started and connectionString points to the correct host/port (e.g., localhost:5432).","cause":"PostgreSQL is not running or connection string is incorrect.","error":"Error: connect ECONNREFUSED ::1:5432"},{"fix":"Make sure to await the initialize() call: const adapter = await initialize(config);","cause":"Likely using `initialize` without await (common mistake in async context).","error":"TypeError: adapter.actor.create is not a function"}],"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":"https://github.com/arobson/consequent-postgres#readme","github":"git://github.com/arobson/consequent-postgres","docs":null,"changelog":null,"pypi":null,"npm":"consequent-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}}