Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

703
Vistas
error: column "..." of relation "..." does not exist

I'm using PostgreSQL with Sequelize in Nodejs. There are 3 tables: tc_user_intervention, tc_interventions and tc_users. tc_user_intervention has 2 fields: userid (from tc_users) and interventionid (from tc_interventions). Here's the Sequelize model (auto-generated from the existing database):

const UserIntervention =  sequelize.define('tc_user_intervention', {
    userid: {
      type: DataTypes.INTEGER,
      allowNull: false,
      references: {
        model: 'tc_users',
        key: 'id'
      }
    },
    interventionid: {
      type: DataTypes.INTEGER,
      allowNull: false,
      references: {
        model: 'tc_interventions',
        key: 'id'
      }
    }
  }, {
    sequelize,
    tableName: 'tc_user_intervention',
    schema: 'public',
    timestamps: false
  });

If I try to do a raw query, everything works, I can insert a new raw into tc_user_interventions:

INSERT INTO `tc_user_intervention`
VALUES (value1, value2);

But if I try to do the same query with Sequelize, I receive the error:

 error: column "id" of relation "tc_user_intervention" does not exist

The query simply is:

UserIntervention.create({ 'userid': user, 'interventionid': intervention});

But Sequelize translate this query into:

sql:
      'INSERT INTO "public"."tc_user_intervention" ("id","userid","interventionid") VALUES (DEFAULT,$1,$2) RETURNING "id","userid","interventionid";',

and obviously this give me the error, because the id column does not exist neither in the model nor in the database. Why is this happening?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda