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

@wisemen/nestjs-typeorm

v1.4.1

Published

NestJS and TypeORM utilities, including transaction-aware repositories, read-only connection support, query helpers, and PostgreSQL advisory locks.

Readme

@wisemen/nestjs-typeorm

NestJS and TypeORM utilities, including transaction-aware repositories, read-only connection support, query helpers, and PostgreSQL advisory locks.

Run Exclusive PostgreSQL Work

Use advisoryLock when application instances must coordinate work, such as a scheduled import or singleton worker task. It supports blocking and non-blocking acquisition, exclusive and shared locks, and PostgreSQL's one- and two-key lock forms.

Call it as advisoryLock(dataSource, acquisition, mode, key, callback) for a single key, or advisoryLock(dataSource, acquisition, mode, namespace, key, callback) for two keys.

import { advisoryLock, tryAdvisoryLock } from '@wisemen/nestjs-typeorm'

const result = await tryAdvisoryLock(
  this.dataSource,
  'exclusive',
  42_001,
  async () => {
    await this.importUsers()
    return 'imported'
  }
)

if (!result.acquired) {
  // Another application instance is already importing users.
  return
}

console.log(result.value)

tryAdvisoryLock always uses non-blocking acquisition and PostgreSQL's pg_try_advisory_lock functions. When another session holds an incompatible lock, the callback is not called and the result is { acquired: false }. A successful callback is { acquired: true, value }, so its value can safely be null or undefined.

Pass 'blocking' as the second argument when the caller should wait for the lock. In this mode, the function returns the callback result directly.

await advisoryLock(
  this.dataSource,
  'blocking',
  'shared',
  7,
  42,
  async () => {
    await this.readSnapshot()
  }
)

Use tryAdvisoryLock(dataSource, mode, key, callback) for a non-blocking single-key lock, or tryAdvisoryLock(dataSource, mode, namespace, key, callback) for its two-key form. advisoryLock accepts the acquisition strategy ('blocking' or 'non-blocking') as its second argument and the lock mode as its third. Use 'shared' when concurrent holders may share the lock; an exclusive lock conflicts with both modes. The lock is released when the callback completes or throws. This utility requires a PostgreSQL data source.

Choose a stable, unique safe-integer lock key for each exclusive operation. Avoid using the same key for unrelated work because PostgreSQL advisory locks share a database-wide key space. Pass namespace and key as separate arguments for PostgreSQL's two signed-32-bit-integer key form; it uses a distinct key space from the single-key form.