orn.js β Sweet, portable ORM for JSON
Single-file, zero-dependency JavaScript ORM + JSON DB. Designed for developer happiness β readable, productive, and production-ready.
Why orn.js?
- Plug into any project with one file β no build step required.
- Human-first ORM syntax (inspired by Rails). Learn in minutes.
- Fallback JSON storage when binaries like SQLite arenβt available.
- Designed for DevX and scale-ready architecture for future sharding & replication.
Quick Example β Node
// import (CommonJS) const orn = require('./orn.js')(); (async()=>{ const db = orn.db(); const users = db.model('users'); const u = await users.create({name:'Alice',email:'alice@example.com'}); console.log('created', u); const found = await users.find(u.id); console.log(found); })();
Docs β orn.js (single-file)
Concise API for common tasks. Everything below runs with no external dependency.
Initialization
// Node (CommonJS) const orn = require('./orn.js')({ root:'./data' }); // optional root folder const db = orn.db(); // Browser (ES module) /* */
Models & CRUD (DevX-friendly)
// Create const users = db.model('users'); const alice = await users.create({name:'Alice', email:'a@x.com'}); // Read const u = await users.find(alice.id); const all = await users.all(); // Update await users.update(alice.id, {email:'alice@new.com'}); // Delete await users.delete(alice.id);
Querying
// Filters: pass a predicate const active = await users.where(u => u.active).all(); // Simple SQL-like (v1) const rows = await db.query('SELECT * FROM users');
Relations (example)
// Define by convention: user_id on posts const posts = db.model('posts'); await posts.create({title:'Hello', user_id:alice.id}); // Load by query const alicePosts = (await posts.where(p=>p.user_id===alice.id)).all();
Persistence
Files stored as NDJSON + WAL. Use db.compactAll()
to compact storage in v1.
Extensions & Roadmap
- Indexing & secondary indexes
- MVCC snapshots & transactions
- CLI admin & tiny admin UI
- WASM/browser full SQL support
About orn.js
orn.js is created to be a sweet, portable ORM for JavaScript developers. Built as a single-file library so it can be embedded into small apps, edge functions, or served from static hosting β no build required.
Philosophy
Developer Experience first β concise API, readable code, no friction. Make it effortless for juniors, powerful for seniors.
Team & Credits
Created by John Kesh Mahugu. Community contributions welcome β open-source MIT.
User Manual
A short manual covering installation, API reference, and best practices.
Installation
// Simply copy orn.js to your project root. // Node: require('./orn.js')() // Browser: (or import as ES module)
Best practices
- Use compactAll() periodically for long-running apps.
- Back up NDJSON files to external storage.
- Use environment-specific roots for multi-tenant deployments.
Contact Us
Questions, enterprise support, or contributions β reach out below.
Legal
License
MIT License Copyright (c) 2025 John Kesh Mahugu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction...
Privacy Policy (short)
This demo site does not collect personal data persistently. Contact messages are not stored by default. When integrating into your app, follow local laws and best practices for user data protection.