npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@castore/event-storage-adapter-postgres

v2.4.2

Published

DRY Castore EventStorageAdapter implementation using Postgres

Downloads

612

Readme

Postgres Event Storage Adapter

DRY Castore EventStorageAdapter implementation using a Postgres database.

📥 Installation

# npm
npm install @castore/event-storage-adapter-postgres

# yarn
yarn add @castore/event-storage-adapter-postgres

This package has @castore/core as peer dependency, so you will have to install it as well:

# npm
npm install @castore/core

# yarn
yarn add @castore/core

👩‍💻 Usage

import { PostgresEventStorageAdapter } from '@castore/event-storage-adapter-postgres';

const pokemonsEventStorageAdapter = new PostgresEventStorageAdapter({
  // 👇 You can specify a connection string for your Postgres database
  connectionString: 'postgresql://postgres:postgres@localhost:5432/postgres',
});

const pokemonsEventStore = new EventStore({
  ...
  eventStorageAdapter: pokemonsEventStorageAdapter,
});

🤔 How it works

This adapter simply persists events in a Postgres database.

Database Table Structure and Customization

Below is an overview of the underlying table structure used by the adapter and the available customization options when creating the event table.

Table Structure Overview

| Column | Data Type(s) | Default Customization | Description | | -------------- | ----------------------------------------------------------- | ------------------------- | ------------------------------------------------------------------------------- | | id | BIGSERIAL (or SERIAL if specified via idType) | BIGSERIAL | Primary key; auto-incrementing identifier | | aggregate_name | VARCHAR(aggregateNameLength) | VARCHAR(32) | Aggregate name (identifies the event store) | | aggregate_id | UUID, ULID, or VARCHAR(aggregateId.length if type is VARCHAR) | UUID | Identifier for the aggregate; if using VARCHAR, a length must be specified | | version | BIGINT (or INTEGER if specified via versionType) | BIGINT | Event version number | | type | VARCHAR(typeLength) | VARCHAR(64) | Name of the event type | | data | JSONB | n/a | Event payload stored in JSONB | | metadata | JSONB | n/a | Additional event metadata | | timestamp | TIMESTAMPTZ with DEFAULT CURRENT_TIMESTAMP(3) | CURRENT_TIMESTAMP(3) | Timestamp of the event (set automatically at insertion) | | UNIQUE | (aggregate_name, aggregate_id, version) | n/a | Enforces that each combination of aggregate_name, aggregate_id, and version is unique |

Customizable Options in createEventTable

| Option | Default Value | Allowed Values / Description | | ------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------ | | tableName | event | Name of the table to be created | | idType | BIGSERIAL | Database type for the id column; allowed values: BIGSERIAL or SERIAL | | aggregateNameLength | 32 | Length for the aggregate_name VARCHAR column | | aggregateId | { type: "UUID" } | Defines the aggregate_id column type; can be UUID, ULID, or VARCHAR (if using VARCHAR, a length must be provided) | | versionType | BIGINT | Database type for the version column; allowed values: BIGINT or INTEGER | | typeLength | 64 | Length for the type VARCHAR column |

Additionally, indexes are created on aggregate_name, version, and a composite index on (aggregate_name, aggregate_id) to enhance query performance.