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

@nathapp/nestjs-data

v3.3.0

Published

ORM-agnostic data access abstractions for NestJS

Readme

@nathapp/nestjs-data

ORM-agnostic data access abstractions — a portable repository contract and transaction-manager interface, with no NestJS or ORM runtime imports.

Installation

npm install @nathapp/nestjs-data

This is a peer-layer library in the @nathapp/nestjs-* stack: it defines the contract, not the implementation. Concrete implementations live in @nathapp/nestjs-prisma (AbstractPrismaRepository) and @nathapp/nestjs-typeorm (AbstractTypeOrmRepository).

What it provides

  • IRepository<TDomain, TId> — portable repository contract: findById, findOne, findAll (paginated), count, create, update, delete. Services depend on this interface via a DI token instead of a concrete ORM repo class.
  • IPageResult<T> — ORM-agnostic paginated result shape (total, current, size, hasNext, hasPrev, records), structurally compatible with Page<T> from @nathapp/nestjs-common.
  • ITransactionManager — ORM-agnostic transaction control built on AsyncLocalStorage: run(fn), getClient<C>(), isInTransaction().
  • TRANSACTION_MANAGER — global DI token (Symbol.for('TRANSACTION_MANAGER')) for the default connection's ITransactionManager. Multi-DB apps must use named tokens instead (see the concrete ORM package's docs).

Usage

Services depend on IRepository<TDomain> and ITransactionManager via DI tokens, never on a concrete ORM class:

import { Inject, Injectable } from '@nestjs/common';
import { IRepository, ITransactionManager, TRANSACTION_MANAGER } from '@nathapp/nestjs-data';

export const USER_REPOSITORY = Symbol('USER_REPOSITORY');

interface User {
  id: string;
  email: string;
}

@Injectable()
export class UserService {
  constructor(
    @Inject(USER_REPOSITORY) private readonly users: IRepository<User>,
    @Inject(TRANSACTION_MANAGER) private readonly tx: ITransactionManager,
  ) {}

  async register(input: User) {
    return this.tx.run(async () => {
      const existing = await this.users.findOne({ email: input.email });
      if (existing) throw new Error('email already registered');
      return this.users.create(input);
    });
  }

  async list(page: { current: number; size: number }) {
    return this.users.findAll(page); // -> IPageResult<User>
  }
}

Bind USER_REPOSITORY to a concrete implementation (e.g. AbstractPrismaRepository subclass from @nathapp/nestjs-prisma) in your module's providers. For ORM-specific power (Prisma include, TypeORM QueryBuilder, raw SQL), inject the concrete repo class directly — those call sites intentionally give up portability.

Limitations

Concrete base classes structurally assume the primary key property is named "id". Schemas using a different PK name must implement IRepository directly rather than extending the abstract base class.