Sequelize
Introduction
JCC Express MVC supports Sequelize as an alternative ORM path through DatabaseServiceProvider and SequelizeDriver.
When enabled, the framework resolves a Sequelize connection and aliases it as:
database.connectionsequelize
Enable Sequelize
Set env/config to use Sequelize:
app/Config/database.ts already contains the expected sequelize block:
Required packages
Install Sequelize and a SQL driver package:
For PostgreSQL or SQLite, install the matching dialect package(s).
Generate models (recommended)
Do not manually create model files for this flow. Use ArtisanNode:
SequelizeDriver auto-loads models from app/Models, so generated model files are discovered at connect time.
Sequelize model example
In Sequelize mode, model files in app/Models should follow Sequelize's Model.init(...) pattern:
What the driver does on connect
From SequelizeDriver:
- creates Sequelize instance with your config
- calls
authenticate() - auto-loads model files from
app/Models - runs
sequelize.sync(config.sync) - optionally drops tables when
dropTablesis enabled
Access the Sequelize connection
To get the Sequelize instance:
The connection is registered as a singleton by DatabaseServiceProvider.
Notes
- Sequelize setup is selected by
DB_ORM=sequelize. - Model loading scans
app/Modelsfor.ts/.jsfiles. - Keep
sync.force/dropTablesdisabled in production unless intentionally resetting schema.
Summary
- Set
DB_ORM=sequelize. - Configure
app/Config/database.ts->sequelize. - Install required npm packages.
- Generate models with
bun artisanNode make:model User. - Resolve connection via
app.resolve("sequelize").
