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

349
Views
Sequelize.create() is not a function

I'm trying to push my DB with sequelize, but it doesn't works, i have this schema for DB

module.exports = (sequelize, DataTypes) => {
    const Problems = sequelize.define("Posts", {
      theme: {
        type: DataTypes.STRING,
        allowNull: false,
      },
      name: {
        type: DataTypes.STRING,
        allowNull: false,
      },
      condition: {
        type: DataTypes.STRING,
        allowNull: false,
      },
      answer: {
        type: DataTypes.STRING,
        allowNull: false,
      },
      answer2: {
        type: DataTypes.STRING,
        allowNull: true,
      },
      answer3: {
        type: DataTypes.STRING,
        allowNull: true,
      },
      username: {
        type: DataTypes.STRING,
        allowNull: false,
      },
    });
  
    return Problems;
  };

and in my connection file:

const express = require("express");
const router = express.Router();
const Problems = require('../models/Problems');

router.get("/", async (req, res) => {
  res.send("hi")
});

router.post("/", async (req, res) => {
  const problem = req.body;
  await Problems.create(problem);
  res.json(problem);
});

module.exports = router;

So, when i Try to post data with Insomnia ai've got the next error: Cannot read property 'create' of undefined

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Please try the following;

const Problems = require('../models/Problems').Posts;
about 4 years ago · Juan Pablo Isaza Report
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!