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

@vendredix/database-pg

v0.25.2

Published

PostgreSQL database module in TypeScript

Downloads

307

Readme

@vendredix/database-pg

NPM version Downloads

PostgreSQL database module in TypeScript with custom transformers and language service.

TODO: Readme.

Examples

/* entities.ts */
import {Database, Column, constants} from "@vendredix/database-pg";
const {DATE_NOW_STRING} = constants;

@Database.Table()
export class AppGroup {
  @Database.AutoIncrement()
  @Database.PrimaryKey()
  groupId?: number;

  @Database.Column()
  name?: string;

  @Database.Column()
  description?: string;

  @Database.Column()
  created?: Date = DATE_NOW_STRING;
}


@Database.Table()
export class AppUser {
  @Database.AutoIncrement()
  @Database.PrimaryKey()
  userId: number;

  @Database.Unique()
  userName: string;

  @Database.Column()
  email: string | null;

  @Database.ForeignKey(AppGroup)
  @Database.Column()
  groupId: number = 1;

  @Database.Column()
  activated: boolean = false;
  
  @Database.Column({typeName: Column.TYPES.JSONB})
  preferences?: object | null;

  @Database.Method({
    language: "plpgsql",
    name: "user_hasPermission",
  })
  public static hasPermission(@Database.Parameter() userId: number, @Database.Parameter() permissionId: string): Promise<boolean> {
    return <never>`
    DECLARE res boolean;
    BEGIN
      RETURN TRUE;
    END;`;
  }

  public hasPermission(permissionId: string): Promise<boolean> {
    return AppUser.hasPermission(this.userId, permissionId);
  }
}


/* example.ts */
import {db} from "./database";

const QS_GroupUsers = db.compile<"groupId">(c => db.appUser
  .select("userName")
  .where(user => user.groupId === c.groupid)
);
const group1Users = await QS_GroupUsers.prepare({groupId: 1}).toListAsync();

/* Transpiles into:
const QS_GroupUsers = db.appUser
    .select("userName")
    .$where()`${_a => _a._columnAccess(0, "groupId")} = ${_a => _a.$id(c => c.groupid)}`
    .compile();
const group1Users = await QS_GroupUsers.prepare({ groupId: 1 }).toListAsync();
*/

const groupids = [1,2,3];
const users = await db.appUser.select()
  .join(db.appGroup)
  .where((user, group) => user.userName.toLowerCase() !== "test" && group.groupId in groupids)
  .toListAsync();

/* Transpiles into:
const groupids = [1,2,3];
const users = await db.appUser.select()
    .join(db.appGroup)
    .$where()`(LOWER(${_b => _b._columnAccess(0, "userName")}) <> 'test') AND (${_b => _b._columnAccess(1, "groupId")} IN ${groupids})`
    .toListAsync();
*/


await db.appUser.update()
  .setValues((user) => {
    user.someName = `User_${user.groupid}_${user.userName}`;
  })
  .where((user) => user.someName !== "")
  .executeAsync();

/* Transpiles into:
await db.appUser.update()
    .$setValues`${_a => _a._columnAccess(0, "someName")} = CONCAT('User_', ${_a => _a._columnAccess(0, "groupid")}, '_', ${_a => _a._columnAccess(0, "userName")})`
    .$where()`${_b => _b._columnAccess(0, "someName")} <> ''`
    .executeAsync();
*/