Skip to main content

@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

# Generate code from schema
npx an5 generate

# Push schema to database
npx an5 db:push

# Pull schema from database
npx an5 db:pull

# Seed database
npx an5 db:seed

# Compare schema with database
npx an5 db:migrate diff

# Run tests
npm test

Usage

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

const db = new An5ORM();

// 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: 'john@example.com', 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: 'jane@example.com' } });
  await tx.order.create({ data: { userId: user.id, total: 100 } });
});

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

Schema Definition

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

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

Metadata

Release files for an5-orm 1.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for an5-orm 1.0.7
File Size Uploaded Provenance Actions
an5_orm-1.0.7.tar.gz 3.1 kB Without provenance Details for an5_orm-1.0.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for an5-orm 1.0.7
File Interpreter ABI Platform Actions
an5_orm-1.0.7-py3-none-any.whl Python 3 none any Details for an5_orm-1.0.7-py3-none-any.whl

Total release size: 6.2 kB

Release files / an5_orm-1.0.7.tar.gz

Download URL an5_orm-1.0.7.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
1f954c2770fa57a24379d0f40a919df505d4d21c02bbe32f6207806b52ed93a8
BLAKE2b-256 checksum
How to use checksums
db95d5d3b47436fa6e8e29418c73acce3c59e082eaeb2d56e9538a31647436d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / an5_orm-1.0.7-py3-none-any.whl

Download URL an5_orm-1.0.7-py3-none-any.whl
Size 3.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0580b1d87851d11dc3cd07eefafa68460c3211409bbc6e1c3b8cf46daa293b0c
BLAKE2b-256 checksum
How to use checksums
6ad627a1a78021aea8f676ba648d46e4afb411a5dae1bf468e44d4234677c20a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for an5-orm 1.0.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page