orange-orm

Implements Active Record database access in Node.js, Bun, and Deno across multiple SQL databases.

1.0k|22|Updated May 27, 2013
One-click install
npx skills add https://github.com/alfateam/orange-orm --skill orange-orm
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: orange-orm
Source: https://github.com/alfateam/orange-orm
Command: npx skills add https://github.com/alfateam/orange-orm --skill orange-orm

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing and maintaining database access code for Node.js, Bun, or Deno applications often requires boilerplate SQL, manual relation handling, and code generation for type safety. This Skill provides authoritative guidance for using Orange ORM to map tables, query, insert, update, and delete rows with full TypeScript IntelliSense and no code generation.

Core Features & Use Cases

  • Table Mapping and Relationships: Define tables, columns, data types, and relations (hasMany, hasOne, references) with a fluent mapping API.
  • Rich Querying and Active Record Updates: Filter with composable where clauses, eager-load relations via fetching strategies, run aggregates, and persist changes with saveChanges().
  • Multi-Database and Browser Support: Connect to PostgreSQL, SQLite, MySQL, MariaDB, MS SQL, Oracle, SAP ASE, PGlite, and Cloudflare D1, or expose data securely to browsers via Express/Hono adapters.
  • Use Case: A developer building a TypeScript API on PostgreSQL can map an order/customer schema, fetch orders with nested lines and delivery addresses in one query, and update graphs of rows inside a transaction.

Quick Start

Ask the AI to define an Orange ORM table mapping for your schema and write a query that fetches rows with related data using a where filter.

Frequently Asked Questions about orange-orm

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I define table mappings in Orange ORM?

Use orange.map() with x.table() to declare tables and column() to define each column's name, type, and constraints like .primary() and .notNull(). Relationships are added in a second chained .map() call using hasMany, hasOne, and references with .by('foreignKey').

How do I filter rows with relations in Orange ORM?

Pass a where option to getMany or getOne using column operators like eq, greaterThan, contains, and startsWith. Relation sub-filters such as lines.any(), all(), none(), and count() let you filter parents based on child rows.

Which databases does Orange ORM support?

Orange ORM supports PostgreSQL, SQLite, MySQL, MariaDB, MS SQL, Oracle, SAP ASE, PGlite, and Cloudflare D1. Each database has a dedicated connector method on the map object, such as map.postgres() or map.sqlite().

Can Orange ORM be used in the browser?

Yes, through the Express or Hono server adapter, which replays client method calls on the server without exposing raw SQL. The browser client connects via map.http() pointing at the mounted endpoint, and raw SQL queries are blocked over HTTP.

Does Orange ORM require code generation for TypeScript types?

No, Orange ORM provides full IntelliSense directly from the map definition without code generation. Insert payloads, filters, and results are type-checked, and you can extract row types using ReturnType<typeof db.table.tsType>.

How do transactions work in Orange ORM?

Wrap operations in db.transaction() and use the provided tx object for all queries and inserts. If the callback throws, everything rolls back; note that transactions are not supported on Cloudflare D1.