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

718
Views
error: la columna "..." de la relación "..." no existe

Estoy usando PostgreSQL con Sequelize en Nodejs. Hay 3 tablas: tc_user_intervention , tc_interventions y tc_users . tc_user_intervention tiene 2 campos: id de userid (de tc_users ) e id de interventionid (de tc_interventions ). Aquí está el modelo Sequelize (generado automáticamente a partir de la base de datos existente):

 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 });

Si trato de hacer una consulta sin procesar, todo funciona, puedo insertar una nueva sin procesar en tc_user_interventions :

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

Pero si trato de hacer la misma consulta con Sequelize, recibo el error:

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

La consulta simplemente es:

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

Pero Sequelize traduce esta consulta a:

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

y obviamente esto me da el error, porque la columna id no existe ni en el modelo ni en la base de datos. ¿Por qué está pasando esto?

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!