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

node-pgledger

v0.1.13

Published

This repository contains essentials for using [pgledger](https://github.com/pgr0ss/pgledger) on the Node platform. Pgledger is a fantastic and lightweight project for implementing a ledger system on Postgres. By handling the heavy lifting, Pgledger enable

Readme

Node Pg Ledger

This repository contains essentials for using pgledger on the Node platform. Pgledger is a fantastic and lightweight project for implementing a ledger system on Postgres. By handling the heavy lifting, Pgledger enables platform-specific libraries to build on top of it and provide convenient wrapper code for easier usage.

Node PgLedger provides strongly-typed interfaces and convenient methods for interacting with pgLedger, making it easier to integrate ledger functionality into Node applications.

Installation

node-pgdledger is published as a NPM package:

npm install node-pgledger

or using yarn

yarn add node-pgledger

Quick Start

Node-Pgledger has its own database connection that is created using sequelize. You are free to confgiure the Sequelize instantce.

For initilize PgLedger you can follow this template code:

import { PGLedger } from "node-pgledger";

(async () => {
  const pl = await PGLedger.init({
    host: "localhost",
    port: 5432,
    database: "test-ledger",
    username: "postgres",
    password: "postgres",
  });

  // Create a test account
  const accountId = await pl.createAccount("test-account", "USD");
  console.log(accountId);

  // Closes the postgres connections
  await pl.destroy();
})();

Create Account

pgledger supports accounts with both positive and negative balances that is configurable. Every account has a name that and a currency. There is no validation on currency code.

const onlyPositiveBalanceAccountId = await pl.createAccount(
  "usd-account",
  "USD",
  // Allow negative balance
  false,
  // Allow positive balance
  true,
);

createAccount returns a PgId. Every account and transfer on pgledger is identified by a prefixed ULID. PgId is an alias to string.

There is no batch account insertion at this point.

Lookup Accounts

Using an array of ids you can fetch accounts. An array of PglAccount instances will return.

const accountIds = ["pgla_01KAGDF3F9FFFS3D8ER0WPW9V0"]
const accounts = await pl.lookup(accountIds)

Create transfer

Any transfer has a from account and a to account and an amount. All amounts are string.

const fromAccountId = "pgla_01KAGDF3F9FFFS3D8ER0WPW9V0"
const toAccountId = "pgla_01KAM2M4APEQFSF0Z08BW1G7YA"
const transferId = await pl.createTransfer(fromAccountId, toAccountId, "12.2")

TODOs