Introduction
Introduction
Section titled “Introduction”jsorm is a JSON-first ORM for TypeScript focused on clarity, strong typing, and explicit SQL behavior.
What makes jsorm different
Section titled “What makes jsorm different”- JSON-first queries instead of opaque builder chains
- AST-based SQL generation so internal structure stays inspectable
- Type inference from models so
defineModel()becomes the single source of truth - Explicit relation builders for predictable joins and mutations
- Optional migrations so existing databases can be used immediately
Core idea
Section titled “Core idea”You describe intent with plain objects:
const users = await db.get(User, { select: { id: true, name: true, role: { name: true }, }, where: { active: true, },});The ORM turns that into a structured AST and then emits SQL through the configured adapter.
When jsorm fits well
Section titled “When jsorm fits well”- TypeScript backends that want model-driven inference
- teams that prefer explicit SQL semantics over magic
- services using PostgreSQL, MySQL, or SQLite
- apps that want raw SQL access without losing a higher-level API
Best practices
Section titled “Best practices”- Treat model definitions as the single source of truth.
- Keep query payloads readable and close to business intent.
- Use
executeSql()for truly custom statements, not as the default path. - Keep adapter configuration centralized in one connection module.