Registry / database / sequelize-hq

sequelize-hq

JSON →
library5.8.11-0.0.13jsnpmunverified

Sequelize is a promise-based Node.js ORM supporting Postgres, MySQL, MariaDB, SQLite, and Microsoft SQL Server. It offers solid transaction support, relations, eager and lazy loading, read replication, and more. This package (sequelize-hq) is a fork at v5.8.11-0.0.13, adding a safety feature to prevent accidental column deletion on alter sync. It follows SEMVER, requires Node >=6, and ships TypeScript types. Key differentiators include full-featured ORM with multiple database support, active community, and extensive documentation.

npm install sequelize-hq
INSTALL
IMPORT
SIG · SEQUELIZE-HQ
S
sequelize-hq
databasejavascriptv5.8.11-0.0.13
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.

Sequelize
import { Sequelize } from 'sequelize-hq'
const Sequelize = require('sequelize-hq')
ESM import is preferred. CommonJS require works but may lack TypeScript type inference.
DataTypes
import { DataTypes } from 'sequelize-hq'
const { DataTypes } = require('sequelize-hq').DataTypes
DataTypes is a named export. Ensure destructuring from module directly, not from Sequelize instance.
Model
import { Model } from 'sequelize-hq'
import Sequelize, { Model } from 'sequelize-hq'
Model is a named export, not a property on the default export.
Op
import { Op } from 'sequelize-hq'
const Op = require('sequelize-hq').Op
Op is exported as a named symbol. For CommonJS, use destructuring: const { Op } = require('sequelize-hq').

Shows how to establish a Sequelize connection, define a model, sync, and authenticate with configurable environment variables.

import { Sequelize, DataTypes, Model } from 'sequelize-hq'; const sequelize = new Sequelize(process.env.DB_NAME ?? 'test', process.env.DB_USER ?? 'root', process.env.DB_PASS ?? '', { host: process.env.DB_HOST ?? 'localhost', dialect: 'mysql' // or 'postgres', 'sqlite', 'mariadb', 'mssql' }); class User extends Model {} User.init({ username: DataTypes.STRING, birthday: DataTypes.DATE }, { sequelize, modelName: 'user' }); (async () => { try { await sequelize.authenticate(); console.log('Connection has been established successfully.'); // Sync all models await sequelize.sync({ force: true }); console.log('All models synced.'); } catch (error) { console.error('Unable to connect to the database:', error); } finally { await sequelize.close(); } })();
Debug
Known issues
breakingIn v5, Model.init() replaces define() for model definition. define() still works but is deprecated.
fix
Use Model.init() with sequelize instance in options.
affects: >=5.0.0
breakingIn v5, the 'operatorsAliases' option is disabled by default. Using operators like $gt will fail.
fix
Remove operator aliases and use symbol operators from Op: { [Op.gt]: 5 }.
affects: >=5.0.0
deprecatedPromise-based API is deprecated in favor of async/await in v6 (unreleased).
fix
Use async/await instead of .then() chains.
affects: >=5.0.0
gotchaRunning sequelize.sync({ alter: true }) may delete columns if not using the fork's alertAndRemoveChangeColumn option.
fix
Set alertAndRemoveChangeColumn: true in sync options to prevent accidental column deletion, or handle manually.
affects: <=5.8.11-0.0.13
gotchaWhen using ESM, require() may not be available. Use import syntax.
fix
Use import statements as shown in the quickstart.
affects: >=5.0.0
Errors
Common errors & fixes
SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:3306
Database server not running or wrong host/port.
fix
Start your database service or check connection config: host, port, credentials.
SequelizeDatabaseError: Table 'test.users' doesn't exist
Model not synced to database.
fix
Call await sequelize.sync() or manually create the table.
TypeError: Cannot read properties of undefined (reading 'STRING')
Missing import of DataTypes.
fix
Add import { DataTypes } from 'sequelize-hq' at the top of the file.
Upgrade
Version history
5.8.11-0.0.13latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
Meta
2
Resources
sequelize-hq — npm install sequelize-hq · libregistry