Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

287
Views
TypeError: models[model].defineConstraints is not a function

I`m trying to undestand whats going on and why defineConstraints is not a function. can someone help me ?

Heres examples of my code.

index.js

const Sequelize = require('sequelize');
  config = require('config');

const dbConf = config.get('database');
console.log(dbConf);


const sequelize = new Sequelize(dbConf.database, dbConf.user, dbConf.password,{
  dialect: 'postgres',
  host: dbConf.host,
  port: dbConf.port,
  logging: console.log
});

sequelize.Model = Sequelize.Model;

const models = {
  User: sequelize.import(__dirname + '/models/user.js'),
  Service: sequelize.import (__dirname + '/models/service.js'),
  Subscriber: sequelize.import (__dirname + '/models/subscriber.js'),  
};

for(const model in models) {
  models[model].defineConstraints(models);
}

models.Op = Sequelize.Op;
models.sequelize = sequelize;

module.exports = models;
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!