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

@an5/orm

v1.0.8

Published

The lightweight ORM for SQL Server with support for TypeScript, Python, and .NET (C#).

Downloads

1,103

Readme

@an5/orm

SQL Server ORM. Proxy client. CRUD. Vector search. Middleware. Raw queries. Transactions.

Features

  • Proxy Client. Model access. db.modelName syntax.
  • CRUD. findMany, findFirst, findUnique, create, update, delete, upsert.
  • Advanced Queries. OR/AND, nested relations, aggregates, groupBy.
  • Vector Search. Native SQL Server VECTOR_DISTANCE. In-memory fallback.
  • Middleware. Hook ORM operations: logging, auth, validation.
  • Raw Queries. $queryRaw, $executeRaw. Auto NOLOCK.
  • Transactions. $transaction. Rollback support.
  • Schema Generator. Parse .an5 files. Generate TypeScript/Python/.NET code.

Quick Start

Installation

TypeScript / Node.js

npm install @an5/orm

Python

pip install an5-orm

Configuration

cp .env.example .env
# Edit .env. Set DATABASE_URL.

Development Commands

Run from the an5Orm/ repository directory (no separate CLI binary is shipped):

# Generate client code from schema
npm run generate

# Push schema to database
npm run db:push

# Pull schema from database
npm run db:pull

# Seed database
npm run db:seed

# Compare schema with database
npm run db:migrate diff

# Generate migration SQL / show status
npm run db:migrate:generate
npm run db:migrate:status

# Run tests
npm test

Usage

import { An5ORM } from '@an5/orm';

const db = new An5ORM();

The default executor reads the DATABASE_URL environment variable. Schema metadata (model→table mapping, relations, field types) is auto-loaded from the ORM's own generated metadata file an5Metadata.ts (created by npm run generate, configured via outputs.typescript.ormMetadataFile). The ORM owns this metadata locally — it never imports from the generated client package (the client is generated from the ORM).

To provide metadata explicitly instead:

import { An5ORM } from '@an5/orm';
import { modelToTable, relationMap, modelFields } from './an5Metadata';

const db = new An5ORM(undefined, { modelToTable, relationMap, modelFields });

// CRUD Operations const users = await db.user.findMany({ where: { email: { contains: '@example.com' } }, orderBy: { createdAt: 'desc' }, take: 10, });

const user = await db.user.create({ data: { email: '[email protected]', name: 'John' }, });

// Relations const orders = await db.user.findMany({ include: { orders: true }, });

// Vector Search const similar = await db.document.vectorSearch({ vector: [0.1, 0.2, 0.3], take: 5, distanceMetric: 'cosine', });

// Transactions await db.$transaction(async (tx) => { const user = await tx.user.create({ data: { email: '[email protected]' } }); await tx.order.create({ data: { userId: user.id, total: 100 } }); });

// Raw Queries const results = await db.$queryRawSELECT * FROM users WHERE id = ${id};


## Schema Definition

Schema files: `.an5`. Path: `an5Schema/`. SQL Server types.

```an5
model User {
  id        NVARCHAR(1000) @id @default(uuid())
  email     NVARCHAR(255)  @unique
  name      NVARCHAR(255)?
  createdAt DATETIME2      @default(now())
  orders    Order[]

  @@map("users")
}

model Order {
  id        NVARCHAR(1000) @id @default(uuid())
  userId    NVARCHAR(1000)
  total     INT            @default(0)
  user      User           @relation(fields: [userId], references: [id])

  @@map("orders")
}

Supported SQL Server Types

Type mapping: .an5 to TypeScript.

| Schema Type | TypeScript | |-------------|------------| | NVARCHAR(n), VARCHAR(n), CHAR(n), TEXT | string | | INT, SMALLINT, TINYINT, FLOAT, REAL, DECIMAL, NUMERIC | number | | BIGINT | number \| bigint | | BIT | boolean | | DATETIME, DATETIME2, DATE, TIME | Date | | UNIQUEIDENTIFIER | string | | VARBINARY, BINARY, IMAGE | Buffer |

Testing

# Unit tests
node test/unit.test.js

# Generator tests
node test/generator.test.js

# Smoke test
npm test

License

MIT