Registry / storage / jeloquent

jeloquent

JSON →
library4.0.3jsnpmunverified

A micro JavaScript ORM memory store inspired by Laravel Eloquent, version 4.0.3. It provides in-memory data storage with automatic indexing of primary and foreign keys for fast selection of models and relations. Supports relation types: BelongsTo, HasMany, HasManyThrough. Lightweight, designed for Node.js and modern browsers. Not actively maintained (last release 2020). Suitable for small-scale or prototyping applications where database persistence is not required.

npm install jeloquent
INSTALL
IMPORT
SIG · JELOQUENT
J
jeloquent
storagejavascriptv4.0.3
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.

Model
import { Model } from 'jeloquent'
const { Model } = require('jeloquent')
ESM-only; CJS require will fail. Use ESM imports.
Field
import { Field } from 'jeloquent'
import Field from 'jeloquent'
Field is a named export, not default.
HasMany
import { HasMany } from 'jeloquent'
Proper named export.
BelongsTo
import { BelongsTo } from 'jeloquent'
Proper named export.
Database
import { Database } from 'jeloquent'
const Database = require('jeloquent').Database
ESM is recommended; CJS require may work in some environments but is not officially supported.
Store
import { Store } from 'jeloquent'
Named export.

Defines three models (User, Team, Comment) with Eloquent-style relations, creates an in-memory database store, inserts data, and retrieves a record.

import { Model, Field, HasMany, BelongsTo, Database, Store } from 'jeloquent'; class User extends Model { constructor() { const fields = [ new Field('id', true), new Field('name'), new Field('team_id'), new BelongsTo(Team), new HasMany(Comment), ]; super(fields); } } class Team extends Model { constructor() { const fields = [ new Field('id', true), new Field('name'), new HasMany(User), new HasManyThrough(Comment, User), ]; super(fields); } } class Comment extends Model { constructor() { const fields = [ new Field('id', true), new Field('title'), new Field('text'), new Field('user_id'), new BelongsTo(User), ]; super(fields); } } const store = new Store(); store.add(new Database('chess', [User, Team, Comment])); store.use('chess'); User.insert([ { id: 1, name: 'Alice', team_id: 1 }, { id: 2, name: 'Bob', team_id: 1 }, ]); const user = User.find(1); console.log(user.name); // Alice
Debug
Known issues
gotchaAll data is stored in memory only; data loss occurs on process restart.
fix
Use for prototypes or non-persistent contexts; implement persistence manually if needed.
affects: >=0.0.0
gotchaPackage uses ESM modules; require() may not work in Node.js without --experimental-modules flag (or Node < 13.2).
fix
Use import statements or upgrade to Node >= 13.2 with type: 'module' in package.json.
affects: >=4.0.0
gotchaFields with primary key set to true must be unique; duplicate primary keys cause silent overwrite.
fix
Ensure uniqueness of primary key values or use auto-generated temporary keys.
affects: >=0.0.0
deprecatedPackage has not been updated since 2020; may have compatibility issues with newer Node.js versions.
fix
Consider alternatives if you need active maintenance or newer features.
affects: >=4.0.0
Errors
Common errors & fixes
Cannot find module 'jeloquent' or its corresponding type declarations.
Package is ESM-only and may not be recognized by some bundlers or TypeScript without proper configuration.
fix
Ensure your project uses ES modules (e.g., set type: 'module' in package.json) and use import syntax.
TypeError: Class constructor Model cannot be invoked without 'new'
Attempting to instantiate a subclass of Model without using new or extending improperly.
fix
Always use new when creating instances of your model classes, e.g., new User() or User.insert() for bulk.
Field 'id' is not a primary key, but a value with primary key 'undefined' already exists.
Primary key field marked as true but no value provided; triggers auto-generation but may conflict.
fix
Pass a primary key value or allow auto-generated keys (temporary _N keys).
Upgrade
Version history
4.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
23 hits · last 30 days
node
22
Resources
jeloquent — npm install jeloquent · libregistry