Registry / database / guruorm

guruorm

JSON →
library2.1.24jsnpmunverified

guruORM (v2.1.24) is a Node.js ORM inspired by Laravel's Eloquent and Illuminate Database, offering a fluent query builder, ActiveRecord models, migrations, seeding, and support for MySQL, PostgreSQL, SQLite, and SQL Server. It ships TypeScript types and requires peer dependencies for each database driver (pg, mysql2, better-sqlite3, tedious). Compared to Sequelize or TypeORM, guruORM focuses on Laravel-like syntax and zero-config setup for both JavaScript and TypeScript projects. Recent versions have been stable, with regular updates.

npm install guruorm
INSTALL
IMPORT
SIG · GURUORM
G
guruorm
databasejavascriptv2.1.24
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Capsule
import { Capsule } from 'guruorm'
import Capsule from 'guruorm'
Capsule is a named export, not default.
Model
import { Model } from 'guruorm'
const Model = require('guruorm').Model
CommonJS require works, but ESM import is preferred for TypeScript.
DB
import { DB } from 'guruorm'
const { DB } = require('guruorm')
DB is a singleton after Capsule.bootEloquent().
Schema
import { Schema } from 'guruorm'
const Schema = require('guruorm').Schema
Used for creating and dropping tables.

Initializes a guruORM connection, creates a users table via Schema, defines a User model, inserts a record, and fetches all users.

import { Capsule, DB, Schema, Model } from 'guruorm'; const capsule = new Capsule(); capsule.addConnection({ driver: process.env.DB_DRIVER ?? 'sqlite', database: process.env.DB_DATABASE ?? ':memory:', }); capsule.setAsGlobal(); capsule.bootEloquent(); async function main() { await Schema.create('users', (table) => { table.id(); table.string('name'); table.string('email').unique(); table.timestamps(); }); class User extends Model { protected table = 'users'; protected fillable = ['name', 'email']; } await User.create({ name: 'Alice', email: 'alice@example.com' }); const users = await User.all(); console.log(users); } main().catch(console.error);
Debug
Known issues
breakingPeer dependencies must be installed manually; missing driver causes runtime error.
fix
Install the required driver package (e.g., npm install pg for PostgreSQL).
affects: >=2.0.0
breakingModel class properties must be declared in constructor or as instance initializers; using static properties will not work as expected.
fix
Declare properties inside the class body with 'protected' or in constructor.
affects: >=2.0.0
gotchaCalling DB.query() before capsule.bootEloquent() results in undefined behavior.
fix
Always call bootEloquent() before using DB, Schema, or any model.
affects: >=2.0.0
deprecatedThe 'DB.raw()' method is deprecated in favor of using parameterized queries in DB.select().
fix
Use DB.select('SELECT * FROM users WHERE id = ?', [id]) instead.
affects: >=2.1.0
breakingNode.js 16+ is required; Node 14 and below are not supported.
fix
Upgrade Node.js to version 16 or higher.
affects: >=2.0.0
Errors
Common errors & fixes
Error: Cannot find module 'pg'
Missing peer dependency for PostgreSQL driver.
fix
Run: npm install pg
TypeError: Capsule is not a constructor
Incorrect import: default import instead of named import.
fix
Use: import { Capsule } from 'guruorm'
Error: No connection configured
Forgot to call capsule.addConnection() before bootEloquent().
fix
Add a connection with capsule.addConnection(...) before capsule.bootEloquent().
TypeError: Cannot read properties of undefined (reading 'table')
Using a model before calling bootEloquent() or without setting table property.
fix
Ensure bootEloquent() is called and model has table property defined.
Upgrade
Version history
2.1.24latest on npm
Audit
Dependencies
pgoptionalRequired for PostgreSQL support
mysql2optionalRequired for MySQL support
better-sqlite3optionalRequired for SQLite support
tediousoptionalRequired for SQL Server support
Agent activity
6 hits · last 30 days
node
6
Resources
guruorm — npm install guruorm · libregistry