How metaldz/eloquent-orm.js works
Eloquent ORM JS is a Laravel-inspired Node.js/TypeScript ORM and CLI. Its main runtime path exposes models and query helpers, resolves a configured database connection, and performs persistence through SQL or MongoDB drivers; model mixins add relationships, caching, and lifecycle behavior. A parallel CLI supports scaffolding and database migration/seed workflows, with cache setup and management as another capability. The graph uses README claims for unsampled CLI features and omits uncertain internal dispatch details; sampled source establishes the model, connection, cache, and scaffold links shown.
Main entry points: index.ts Public API · BaseModel.ts Model API · CoreModel.ts Persistence and queries · TransactionManager.ts Transactions and locks
Components 27
ORM runtime
- Public API
src/index.ts - Model API
src/core/model/BaseModel.ts - Persistence and queries
src/core/model/CoreModel.ts - Safe finders
src/core/model/SafeFinder.ts - Relations and mixins
src/core/orm
Connections and schema
- Schema blueprint
src/core/schema/SchemaBlueprint.ts - Schema builder
src/core/schema/SchemaBuilder.ts - Database configuration
src/config/database.ts - Connection factory
src/core/connection/ConnectionFactory.ts - Database connections
src/core/connection/DatabaseConnection.ts - Driver adapter
src/core/connection/DriverAdapter.ts - Transactions and locks
src/core/connection/TransactionManager.ts
CLI workflows
- CLI command runtime
src/cli/eloquent.ts - Scaffold generators
src/cli/commands - Controller generator
src/cli/commands/makeController.ts - Template engine
src/cli/utils/TemplateEngine.ts - Scaffold support
src/cli/utils/ScaffoldGeneratorSupport.ts - Artifact writer
src/cli/utils/fileWriter.ts - Migration and seed commands
src/cli/commands
Caching
- Cache setup
src/core/cache/setupCache.ts - Cache manager
src/core/cache/CacheManager.ts - Cache drivers
src/core/cache/drivers - Query cache mixin
src/core/orm/mixins/QueryCacheMixin.ts
Other components
- Application developer
- SQL / MongoDB
- CLI user
- Cache backend
Connections 29
- Application developer → Public API: uses
README.md - Public API → Model API: exports
src/index.ts - Public API → Schema blueprint: exports
src/index.ts - Public API → Schema builder: exports
src/index.ts - Public API → Cache manager: exports
src/index.ts - Public API → Transactions and locks: exports
src/index.ts - Model API → Persistence and queries: composes
src/core/model/BaseModel.ts - Model API → Relations and mixins: mixes in
src/core/model/BaseModel.ts - Model API → Query cache mixin: mixes in
src/core/model/BaseModel.ts - Persistence and queries → Safe finders: uses
src/core/model/CoreModel.ts - Persistence and queries → Connection factory: gets connection
src/core/model/CoreModel.ts - Persistence and queries → Schema blueprint: validates schema
src/core/model/CoreModel.ts - Connection factory → Database configuration: reads config
src/core/connection/ConnectionFactory.ts - Connection factory → Database connections: creates connection
src/core/connection/ConnectionFactory.ts - Database connections → SQL / MongoDB: connects
src/core/connection/DatabaseConnection.ts - Transactions and locks → Connection factory: gets connection
src/core/connection/TransactionManager.ts - Transactions and locks → Database connections: opens connection
src/core/connection/TransactionManager.ts - Transactions and locks → Driver adapter: creates adapter
src/core/connection/TransactionManager.ts - CLI user → CLI command runtime: runs commands
README.md - CLI command runtime → Scaffold generators: dispatches
- CLI command runtime → Migration and seed commands: dispatches
- Scaffold generators → Controller generator: includes
src/cli/commands/makeController.ts - Controller generator → Template engine: renders template
src/cli/commands/makeController.ts - Controller generator → Scaffold support: resolves artifact
src/cli/commands/makeController.ts - Controller generator → Artifact writer: writes output
src/cli/commands/makeController.ts - Cache setup → Cache drivers: selects drivers
src/core/cache/setupCache.ts - Cache setup → Cache manager: configures
src/core/cache/setupCache.ts - Cache manager → Cache backend: reads and writes
src/core/cache/CacheManager.ts - Query cache mixin → Cache manager: uses
src/core/orm/mixins/QueryCacheMixin.ts