Skip to main content
The Sequelize datasource allows importing collections from a Sequelize instance, preserving your ORM configuration including scopes, hooks, associations, and validations.
Sequelize datasource is only available for Node.js. For Ruby, check the ActiveRecord datasource.

Basic usage

Features

The Sequelize datasource automatically preserves your ORM configuration:
  • Sequelize scopes - Mapped to Forest segments
  • Sequelize hooks - Bulk hooks run; per-record hooks do not (see below)
  • Associations - Relationships are automatically recognized
  • Validations - Enforced on edit, skipped on create (see below)

Which hooks run on a write from Forest

Forest writes through bulkCreate, update and destroy without individualHooks, so only bulk hooks fire:
A per-record hook that enforces an invariant, such as writing an audit row, won’t fire on a Forest edit. Move it into an agent hook.
The SQL datasource never loads your models, so none of your hooks or validations apply to it.

Live Query support

Enable SQL-based reporting by setting a connection identifier:
This allows authorized users to create Live Query charts, analytics, and segments that execute custom SQL directly against your database.
Live Queries execute raw SQL. Ensure proper access controls and review queries before deploying to production.

Source code

This connector is open source. Browse the code or contribute on GitHub: @forestadmin/datasource-sequelize.