Socket
Book a DemoInstallSign in
Socket

@alepha/postgres

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alepha/postgres

A type-safe SQL query builder and ORM using Drizzle.

0.9.4
latest
Source
npmnpm
Version published
Weekly downloads
53
-36.14%
Maintainers
1
Weekly downloads
 
Created
Source

Alepha Postgres

A type-safe SQL query builder and ORM using Drizzle.

Installation

This package is part of the Alepha framework and can be installed via the all-in-one package:

npm install alepha

Alternatively, you can install it individually:

npm install @alepha/core @alepha/postgres

Module

Postgres client based on Drizzle ORM, Alepha type-safe friendly.

const users = $entity({
  name: "users",
  schema: t.object({
    id: pg.primaryKey(),
    name: t.string(),
    email: t.string(),
  }),
});

class Db {
  users = $repository(users);
}

const db = alepha.inject(Db);
const user = await db.users.one({ name: { eq: "John Doe" } });

This is not a full ORM, but rather a set of tools to work with Postgres databases in a type-safe way.

It provides:

  • A type-safe way to define entities and repositories. (via $entity and $repository)
  • Custom query builders and filters.
  • Built-in special columns like createdAt, updatedAt, deletedAt, version.
  • Automatic JSONB support.
  • Automatic synchronization of entities with the database schema (for testing and development).
  • Fallback to raw SQL via Drizzle ORM sql function.

Migrations are supported via Drizzle ORM, you need to use the drizzle-kit CLI tool to generate and run migrations.

Relations are NOT SUPPORTED yet. If you need relations, please use the drizzle-orm package directly.

API Reference

Descriptors

$entity()

Declare a new entity in the database. This descriptor alone does not create the table, it only describes it. It must be used with $repository to create the table and perform operations on it.

This is a convenience function to create a table with a json schema. For now, it creates a drizzle-orm table under the hood.

import { $entity } from "@alepha/postgres";

const User = $entity({
  name: "user",
  schema: t.object({
    id: pg.primaryKey(t.uuid()),
    name: t.string(),
    email: t.string(),
  }),
  indexes: ["email"],
});

$repository()

$sequence()

$transaction()

Keywords

alepha

FAQs

Package last updated on 21 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.