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

@teliagen/persistence

v0.4.2

Published

ORM and data persistence for Teliagen

Readme

@teliagen/persistence

The universal data mappers and ORM abstraction layer for Teliagen.

@teliagen/persistence provides a powerful Active Record implementation that decouples your entities from the underlying database driver. Whether you use Postgres, MySQL, or Mongo, your business logic remains robust and unchanged.

npm version License

Features

  • Universal Entities: Define models once using decorators (@Entity, @Column).
  • Active Record: Intuitive API (User.findById, user.save()).
  • Adapter System: Pluggable backends (Sequelize, TypeORM, Prisma, In-Memory).
  • Rich Relationships: Built-in support for OneToOne, OneToMany, and ManyToMany.
  • Microservices Ready: Define @RemoteEntity to reference data across services.

Installation

npm install @teliagen/persistence

You will also need a database adapter (e.g., @teliagen/adapter-sequelize).

Quick Start

1. Define an Entity (src/modules/users/entities/user.entity.ts)

Entities are standard TypeScript classes decorated with metadata.

import { Entity, Column, Model } from '@teliagen/persistence/entities';
import { DataType } from '@teliagen/persistence/database';

@Entity({ tableName: 'users' })
export class User extends Model {
  
  @Column({ primary: true, type: DataType.UUID, defaultValue: DataType.UUIDV4 })
  id!: string;

  @Column({ type: DataType.STRING, required: true })
  name!: string;

  @Column({ type: DataType.STRING, unique: true })
  email!: string;
}

2. Configure Adapter (src/bootstrap.ts)

Connect your application to the database.

import { TeliagenApp } from '@teliagen/server/app';
import { SequelizeAdapter } from '@teliagen/adapter-sequelize';
import { User } from './modules/users/entities/user.entity.js';

const app = new TeliagenApp();

const adapter = new SequelizeAdapter({
  dialect: 'postgres',
  host: process.env.DB_HOST,
  password: process.env.DB_PASSWORD,
  database: 'my_app'
});

// 1. Bind adapter to the Framework
app.useDataAdapter(adapter);

// 2. Register Entities
app.registerModule({
  entities: [User]
});

// 3. Sync Schema (Dev only) & Start
await app.initialize();
await adapter.connect();
await adapter.syncSchema({ alter: true });

await app.start();

3. Use Data (src/modules/users/actions/user.actions.ts)

Perform CRUD operations effortlessly.

import { ActionProvider, Action, Input } from '@teliagen/commons/actions/decorators';
import { User } from '../entities/user.entity.js';
import { CreateUserInput } from '../schemas/create-user.schema.js';

@ActionProvider({ module: 'users', name: 'UserActions' })
export class UserActions {

  @Action('create')
  async create(@Input() input: CreateUserInput) {
    // Active Record pattern
    const user = await User.create({
      name: input.name,
      email: input.email
    });
    
    return user;
  }
}

Core Concepts

Model API

Every entity extends Model, inheriting powerful static and instance methods:

  • Finders: findById, findOne, findAll, count
  • Mutations: create, update, destroy
  • Instance: save, reload, toJSON

Associations

Define relationships clearly using decorators:

@Entity()
class Post extends Model {
  @ManyToOne(() => User)
  author!: User;
}

@Entity()
class User extends Model {
  @OneToMany(() => Post)
  posts!: Post[];
}

Documentation

For query builders, transactions, and advanced usage, visit:

docs.teliagen.org

License

Apache-2.0