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

npm 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.6

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.6
File Size Uploaded Provenance Actions
an5_orm-1.0.6.tar.gz 3.1 kB Without provenance Details for an5_orm-1.0.6.tar.gz

Built distribution (wheel)

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

Total release size: 6.2 kB

Release files / an5_orm-1.0.6.tar.gz

Download URL an5_orm-1.0.6.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
57c465e3005312e4f36858c541deeb799bf7ed952729060f8683eebecbf53105
BLAKE2b-256 checksum
How to use checksums
2640a37ce81eacfd32d9a7fa2a1868ba86c105c810ebb422ccffcb646f242da3
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.6-py3-none-any.whl

Download URL an5_orm-1.0.6-py3-none-any.whl
Size 3.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
07612a19c3f200ed6577fe083d6411fcf8a4a3362f0181889da9b35f5d5ea00c
BLAKE2b-256 checksum
How to use checksums
ce0d5bc05c4142c5886c63384c900b8971a929c704c65aacc3682097162ffd43
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.6

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